Postgresql - detect changes and call webservice

后端 未结 1 1852
-上瘾入骨i
-上瘾入骨i 2020-12-16 10:51

I have a PostgreSQL database. What I want to do is, detect any changes (insert, update) that happen in the database and then call a webservice. How could I do this?

相关标签:
1条回答
  • 2020-12-16 11:25

    You should be able to use triggers and the listen/notify functionality in PostgreSQL to achieve something like this:

    1. A set of insert/update/delete triggers create a notification event whenever anything changes in your table, using the created/changed/deleted ID as the payload.

    2. A background process checks for notifications periodically (here's an example using Java/JDBC), and then loads the changed record from the database to do the web service call.

    This is not in any way a real-time push-type system, but you have to poll the database for notification events to trigger the webservice call. It will do the trick, though.

    0 讨论(0)
提交回复
热议问题