473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

notify problem

Hi to all

I have problem with NOTIFY/LISTEN ...
I'm writing a C++ application with libpqxx, I thought was a problem of
the lib but I try also with a C program using libpq with the same
result, so maybe there is something else of wrong.

Using the example 2 in the libpq chapter on "Postgres Programmer's
Guide" as template i write :

!---------->
#include <unistd.h>
#include <libpq-fe.h>

int main() {

PGconn *conn;
PGresult *res;
PGnotify *notify;

int i;

conn = PQconnectdb ("host=localhost user=test dbname=test");

if (PQstatus(conn) == CONNECTION_BAD) {
fprintf(stderr,"failed connecting.\n");
PQfinish(conn);
exit(1);
}

res = PQexec(conn, "LISTEN alert");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
fprintf(stderr,"failed listening.\n");
PQclear(res);
PQfinish(conn);
exit(1);
}

PQclear(res);

for(i = 0; i < 80 ; ++i) {
sleep(1);
PQconsumeInput(conn);
while ((notify = PQnotifies(conn)) != NULL) {
fprintf(stderr,"\nGOT NOTIFY!!!\n");
free(notify);
}
fprintf(stderr,".");
}

PQfinish(conn);

return 0;
}
<----------!
On a console with psql I issue some notify with
NOTIFY alert; COMMIT;

but nothing are catched !!!

if in another console with psql i do a "LISTEN alert;" all work
correctly.

I'm using Linux, RedHat 9, so PostgreSQL 7.3.2.
user and database are created with :
createuser -h localhost -U postgres -D -A -P test
createdb -O test -h localhost -U postgres test

and nothing alse, the database are empty.

what's wrong ???

Thanks.
--
Alessandro GARDICH <gr*****@gremlin.it>
gremlin.it

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #1
1 2794
Alessandro GARDICH <gr*****@gremlin.it> writes:
res = PQexec(conn, "LISTEN alert"); for(i = 0; i < 80 ; ++i) {
sleep(1);
PQconsumeInput(conn);
while ((notify = PQnotifies(conn)) != NULL) {
fprintf(stderr,"\nGOT NOTIFY!!!\n");
free(notify);
}
fprintf(stderr,".");
} On a console with psql I issue some notify with
NOTIFY alert; COMMIT;
but nothing are catched !!!


Hm. Should I guess from the above that you've set autocommit off in
postgresql.conf? If so, your problem is you didn't commit the LISTEN.
Notifications are not sent to clients that are in open transactions.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rob | last post by:
I have an interesting problem with my Notify Icon. I cannot get it to display when I start a web service. I have no problems when I test the software on a Windows program. But the Icon will not...
4
by: Joe Lester | last post by:
I'm using PostgreSQL 7.4.1. I have 140 clients connected on average using libpq. When one client sends "NOTIFY timeclock;" to the server all 140 clients are listening for it. After receiving a...
3
by: Frank van Vugt | last post by:
L.S. Either the docs or I are missing something.... While using libpq I noticed that listen/notify calls were being converted to lowercase. A further look showed that the listen/notify calls...
3
by: Mark Denardo | last post by:
Does anyone have any good VB.NET example code that shows how to use the NOTIFY option using the mciSendString API and then handle the return value. The only examples I can find show the VB way...
0
by: Mike Eaton | last post by:
Hi there, I have an app whose structure is as follows: a module calls a custom application context containing a notify icon and associated context menu, which in turn acts upon an instance of...
3
by: Cylix | last post by:
I am going to make an application in monitor and do something on time. A part of it is an Notify icon(System Tray Icon), Which project type can I be used for Just showing the notify icon without...
1
by: liubin | last post by:
I'm trying to create a context menu that pops up upon right clicking the notify icon of my application. The menu works great with plain text... no problem. My problem is that I want to add some...
1
by: namrataa | last post by:
i have a notify icon for our media player developed in wpf. included files are notify.cs,notify.resx,notify.designer.cs. i have also added a class file called app.cs . now the problem is how...
2
by: greyradio | last post by:
I've recently have been given an assignment to do and it seems that notify() does notify() any of the waiting threads. The project entails 10 commuters and two different toll booths. The EZPass booth...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.