PostgreSQL-检测更改并调用Web服务 [英] Postgresql - detect changes and call webservice

查看:124
本文介绍了PostgreSQL-检测更改并调用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PostgreSQL数据库。我想做的是,检测数据库中发生的任何更改(插入,更新),然后调用Web服务。我该怎么办?

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?

在此先感谢您的帮助。

推荐答案

您应该能够使用触发器和侦听/通知PostgreSQL中的功能实现以下目标:

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


  1. 一组插入/更新/删除触发器都会创建一个通知事件,并使用创建/更改/删除的ID作为有效内容。

  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.

一个后台进程定期检查通知(这是一个使用Java的示例/ JDBC ),然后从数据库加载更改的记录以进行Web服务调用。

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.

这绝对不是实时推送类型的系统,但是您必须轮询数据库以获取通知事件,以便gger网络服务调用。不过,它将成功。

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.

这篇关于PostgreSQL-检测更改并调用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆