javadatabasepostgresqljmspublishing

PostgreSQL and JMS (Or other Pub-Sub/Callback Mechanism)


I want to have my PostgreSQL server send out notifications when a piece of data changes, preferably over JMS, but also considering any other Pub-Sub mechanism or Callback.

Any ideas if this is possible?

Are there any available Java Add-on Packages that replicate this sort of functionality?


Solution

  • EDIT: I've been informed that PostgreSQL does support stored procedures in Java. That means the following approach becomes feasible:

    Essentially, the way I would go is to put a trigger on whatever it is you want to watch, and then call a stored procedure from that. The stored procedure then needs to communicate with the world outside the DB server; I once did an SP like this in Java that opened up a socket connection to a process on the same server listening on a port. If worst came to worst, you could maybe write a file and have something like imon monitoring that file, or you could start up a program in an exec() shell of its own... something like that.