Hello,
I found the example code in the documentation of the JDBC driver is misleading. The example receiving code displayed on https://jdbc.postgresql.org/documentation/head/listennotify.html issues a SELECT 1 everytime before it checks for notifications, which made me believe the driver is not able to receive notifications without having to hit the database.
After checking the source (because I tried to implement something that does not have this requirement) I found out this select is useless at least in the current state of the driver, which makes the drivers implementation much more appealing to me. Please remove the seven lines
// issue a dummy query to contact the backend
// and receive any pending notifications.
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1");
rs.close();
stmt.close();
from the example code.
Regards,
Daniel Migowski