I'm trying to listen for notify events using libpqxx. I started by going off an example that extended pqxx::notify_listener
.
#include <iostream>
#include <string>
#include <pqxx/pqxx>
class Foo : public pqxx::notify_listener {
public:
Foo(pqxx::connection_base &c): pqxx::notify_listener(c, "listen") {}
virtual void operator()(int id) { std::cout << "HERE!" << std::endl; }
};
int main(void) {
// set up the listener
pqxx::connection con("...secret...");
Foo listener(con);
// loop forever ...
}
I couldn't get this working though.
I tried switching the name parameter topqxx::notify_listener(c, "my_schema")
,pqxx::notify_listener(c, "listen my_schema")
and some others.
I am creating the NOTIFY events manually via a pgAdmin. no matter what I do, the functor doesn't get executed.
Do you call pqxx::connection_base::get_notifs()
or pqxx::connection_base::await_notification()
in the main loop?
If not, you need to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With