473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=localhos t 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_O K) {
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*****@gremli n.it>
gremlin.it

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

http://archives.postgresql.org

Nov 11 '05 #1
1 2828
Alessandro GARDICH <gr*****@gremli n.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
2096
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 display for the service. My service utilizes an Asynchronous Callback to load a queue. There is other background processing based on time (different thread). I have heard that the Notify Icon may have issues when the thread that instanctiates...
4
2211
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 notification from libpq (PQnotifies), each client proceeds to execute a query for the last five records in the timeclock table. SELECT * FROM timeclock ORDER BY touched DESC LIMIT 5;
3
2139
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 seem to be totally case insensitive: free4testing=# select version(); version
3
4980
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 using <Form>.hWnd My program basically needs to start a media file and then be informed when it has finished. Right now I have to set up a polling thread to check the status of the playing media file, which works, but causes other parts of my...
0
1397
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 another class, I'll call Class1 (i.e. accesses its startup, shutdown, print reports methods). Basically, Class1 manages communication between two other classes: one is a class that listens for a socket connection from another application and the...
3
2028
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 any form? What I mean is something like When you minimize the MSN Messager as a tray icon. I have tried a service project and application project, all these seems cannot meet the goal.
1
1940
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 sparkle by displaying a different highlighting scheme for the individual mouse over events and an icon on each item in the menu. I can do this, and have successfully done this in a regular main menu and a context menu that is set to an item on a...
1
1631
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 do u attach an event handler to the context menu.i want to add event handlers to hide and show the media player. The notify icon appears in the tray when i run the application but does not disappear wen it is stopped.
2
3489
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 allows a commuter to pass easily while a cash booth creates a wait line. The wait line is expected to wait for the 5th commuter to pass before any commuter on the wait line can pass through the toll booth. This is where my problem lies. All the...
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9525
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10221
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10169
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9050
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.