If you're fine with polling a database, here's how to do it:
PGConnection con = ... try (Statement s = con.createStatement()) { s.executeUpdate("listen x"); s.executeUpdate("notify x, 'abc'"); } for (PGNotification n : con.getNotifications()) { System.out.println(String.format("%s, %s, %s", n.getPID(), n.getName(), n.getParameter())); }
The above will give something like:
11796, x, abc 11796, x, xyz
You need to run at least one operator to receive new notifications from the connection.
Lukas Eder Jan 30 '16 at 18:18 2016-01-30 18:18
source share