When fetching http://localhost:3000/test, a row is inserted, and the trigger causes a notification to be sent and received by the server on 3001. The server on 3000 does not receive the notification.
Now fetch http://localhost:3001/test, a new row is inserted and the the server on 3000 receives the first notification and this new one at the same time. The server on 3001 does not receive this notification (until you reverse the process again).
Connecting to the database while these are running with psql and inserting a row will cause the notification to hit both instances, immediately.
test code: https://gist.github.com/tardisx/498997899b8cd1b1430d
setup database, fix db credentials at top of script, then run two instances on different ports:
When fetching http://localhost:3000/test, a row is inserted, and the trigger causes a notification to be sent and received by the server on 3001. The server on 3000 does not receive the notification.
Now fetch http://localhost:3001/test, a new row is inserted and the the server on 3000 receives the first notification and this new one at the same time. The server on 3001 does not receive this notification (until you reverse the process again).
Connecting to the database while these are running with psql and inserting a row will cause the notification to hit both instances, immediately.
Thanks!