问题描述
我正在编写C ++应用程序,该应用程序需要通过库从PostgreSQL接收有关数据更改的通知。 。但是它的不包括这种用例。通知必须通过多个渠道接收。另外,我还在使用作为网络库,对我来说,如果可能的话,最好将 asio 套接字类与异步回调一起用于通知事件,而不是轮询原始BSD样式套接字。有人可以为此提供示例代码,还是可以链接到一些外部资源来实现此目标?
I'm writing C++ applicatoin which needs to receive notifications for data changes from PostgreSQL through libpqxx library. But it's tutorial doesn't include such use case. The notifications must be received on multiple channels. Also I'm using boost::asio as networking library and for me is preferable if possible to use asio socket classes with asynchronous callbacks for notification events instead of polling of raw BSD style sockets. Can someone provide sample code for this or links to some external resources for how this can be achieved?
推荐答案
您需要派生一个类来自 pqxx :: notification_receiver
,请参见通知和接收者和
,这是 notification_receiver
的API参考。
You need a class derived from pqxx::notification_receiver
, see http://pqxx.org/devprojects/libpqxx/doc/4.0/html/Reference/a00208.html "Notifications and Receivers" andhttp://pqxx.org/devprojects/libpqxx/doc/4.0/html/Reference/a00062.html which is the API reference for notification_receiver
.
这篇关于如何使用libpqxx从PostgreSQL数据库接收通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!