From d6989f1e54104d09b8af6d22cf46ea4f6fc5f4dc Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 10 Sep 2014 00:12:30 +0200 Subject: o Initial import of postgresql LISTEN/NOTIFY code. --- .../java/io/trygvis/jz14/demo/NotifierMain.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/io/trygvis/jz14/demo/NotifierMain.java (limited to 'src/main/java/io/trygvis/jz14/demo/NotifierMain.java') diff --git a/src/main/java/io/trygvis/jz14/demo/NotifierMain.java b/src/main/java/io/trygvis/jz14/demo/NotifierMain.java new file mode 100644 index 0000000..12dad41 --- /dev/null +++ b/src/main/java/io/trygvis/jz14/demo/NotifierMain.java @@ -0,0 +1,34 @@ +package io.trygvis.jz14.demo; + +import org.slf4j.Logger; + +import java.sql.Connection; +import java.util.Random; + +import static org.slf4j.LoggerFactory.getLogger; + +public class NotifierMain { + Logger log = getLogger(getClass()); + Db db = new Db("notifier"); + Random r = new Random(); + + public static void main(String[] args) throws Exception { + new NotifierMain().main(); + } + + public void main() throws Exception { + Connection c = db.getConnection(); +// c.setAutoCommit(false); + + int count = 1 + r.nextInt(9); + + for (int i = 0; i < count; i++) { + c.createStatement().execute("NOTIFY mail_raw, '" + i + "';"); + } +// c.commit(); + + log.info("NOTIFY performed, count={}", count); + + c.close(); + } +} -- cgit v1.2.3