我想让我的PostgreSQL服务器在一段数据更改时发送通知,最好是通过JMS,还要考虑任何其他Pub-Sub机制或回调。
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?
是否有任何可用的Java附加软件包可以复制这种功能?
Are there any available Java Add-on Packages that replicate this sort of functionality?
推荐答案编辑:我被告知PostgreSQL 支持Java中的存储过程。这意味着以下方法变得可行:
I've been informed that PostgreSQL does support stored procedures in Java. That means the following approach becomes feasible:
基本上,我想要的方法是将触发器放在你想要观看的任何内容上,然后调用存储过程从那以后。然后,存储过程需要与DB服务器外部的世界通信;我曾经在Java中使用这样的SP来打开与同一服务器上的进程的套接字连接,并监听端口。如果最糟糕的情况发生了,你可以编写一个文件并使用imon监视该文件,或者你可以在自己的exec()shell中启动一个程序......就像那样。
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.
更多推荐
PostgreSQL和JMS(或其他Pub
发布评论