I am writing a database application on PostgreSQL that has two parts:
- GUI – written in Symfony/Doctrine
- Processing – written in C/libpq
The processing component will process data from a table after it has been inserted by the GUI. However, how does the processing component know there is a change? My default answer would have been to use the PostgreSQL notify/listen commands, as I’m keen to avoid some kind of polling.
Questions:
-
Is there some way that the Symfony application could use the postgresql notify command? Doctrine supports Native SQL selects, but I don’t believe this is what I need.
-
Any other ideas?
Thanks in advance.
A native
SELECTshould be entirely sufficient.While you usually use the
NOTIFYstatement, it’s also possible to call thepg_notifyfunction for the same effect.Your worker can
LISTEN key;as normal, and will receive notifications generated this way the same as ifNOTIFYwas used.