NOTIFY tableX, LISTEN tableX, pool Nofities()

Started by Davi Lealabout 24 years ago1 messagesgeneral
Jump to latest
#1Davi Leal
davileal@terra.es

I am developing an n-tier application which uses postgresql 7.2. It has several windows to show Data Base data. If the DB modifies its data then some or each window must update the showed information. To realize it the DB send "NOTIFY <table X changed>".

The problem is that if a window catch a "NOTIFY table1", another window of the same process, which must update too the table1's information, does not update due to the asynchronous notification to this backend has already been processed.

Must I use a thread to each application's window?.

Must I do a central collect of notifies and raise the update of windows from there?. Yes, I think so. :-) However, I need to know the exact type of notify which the backend gets: "NOTIFY table1", "NOTIFY table2", or ...

How could I differentiate from several types of "NOTIFY tableX" ?.

Which are the fields of the PGnotify* PgDatabase::Notifies() ?.

Note: You can see attached examples as C or C++ code which catch the NOTIFY from the data base doing a pool. To compile it on Debian GNU/Linux (sid) you can do:
gcc -o testlibpq2-C testlibpq2.c -I /usr/include/postgresql/ -lpq
g++ -o testlibpq2-C++ testlibpq2.cpp -I /usr/include/postgresql/ -lpq++

Regards,
Davi Leal

Attachments:

testlibpq2.ctext/x-c; charset=iso-8859-1; name=testlibpq2.cDownload
testlibpq2.cpptext/x-c++; charset=iso-8859-1; name=testlibpq2.cppDownload