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 to
pqxx::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.