如何使用libpqxx从PostgreSQL数据库接收通知? [英] How to use libpqxx to receive notifications from the PostgreSQL database?

查看:318
本文介绍了如何使用libpqxx从PostgreSQL数据库接收通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写C ++应用程序,该应用程序需要通过 libpqxx 库从PostgreSQL接收有关数据更改的通知。 。但是它的教程不包括这种用例。通知必须通过多个渠道接收。另外,我还在使用 boost :: asio 作为网络库,对我来说,如果可能的话,最好将 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 ,请参见 http://pqxx.org/devprojects/libpqxx/doc/4.0/html/Reference/a00208.html 通知和接收者和
http://pqxx.org/devprojects/libpqxx/doc/4.0/html/Reference/a00062.html ,这是 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" and http://pqxx.org/devprojects/libpqxx/doc/4.0/html/Reference/a00062.html which is the API reference for notification_receiver.

这篇关于如何使用libpqxx从PostgreSQL数据库接收通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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