How to listen for a Postgresql LISTEN?

classic Classic list List threaded Threaded
6 messages Options
nav
Reply | Threaded
Open this post in threaded view
|

How to listen for a Postgresql LISTEN?

nav
Postgresql has NOTIFY and LISTEN.

I figured out how to issue a NOTIFY command using
FdoPtr<FdoISQLCommand> objSql;
objSql = (FdoISQLCommand*)m_objFDOConnection->CreateCommand(FdoCommandType_SQLCommand);

and
FdoPtr<FdoISQLDataReader> objSqlDataReader;
objSqlDataReader = objSql->ExecuteReader();


but once my FDO application issues a LISTEN command, how can I ensure that when some other client issues NOTIFY, my FDO application will be able to capture the signal received from LISTEN? Is there anything in FDO that can specifically listen for signals from LISTEN?
Reply | Threaded
Open this post in threaded view
|

Re: How to listen for a Postgresql LISTEN?

Jackie Ng
I think you're starting to venture into territory that is not covered by this particular FDO API.

FdoISQLCommand is really for CRUD and DML and not for tapping into esoteric DBMS-specific features.

- Jackie
nav
Reply | Threaded
Open this post in threaded view
|

Re: How to listen for a Postgresql LISTEN?

nav
Thank you Jackie.
So there's absolutely nothing in FDO that can listen for an asynchronous notification? I was hoping there'd be something, because NOTIFY was working and I was looking for a way to implement LISTEN.
If there isn't then I'll have to try a non-FDO technique (which would be weird to use along with existing FDO code).
Reply | Threaded
Open this post in threaded view
|

Re: How to listen for a Postgresql LISTEN?

zspitzer
that said, it's not really that weird given you are already using database specific functionality :)


On Fri, May 24, 2013 at 1:26 PM, nav <[hidden email]> wrote:
Thank you Jackie.
So there's absolutely nothing in FDO that can listen for an asynchronous
notification? I was hoping there'd be something, because NOTIFY was working
and I was looking for a way to implement LISTEN.
If there isn't then I'll have to try a non-FDO technique (which would be
weird to use along with existing FDO code).



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-to-listen-for-a-Postgresql-LISTEN-tp5055214p5055413.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users



--
Zac Spitzer
Solution Architect / Director
Ennoble Consultancy Australia
+61 405 847 168


_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
nav
Reply | Threaded
Open this post in threaded view
|

Re: How to listen for a Postgresql LISTEN?

nav
@zspitzer: The problem is that I'm not really sure how to make the c++ client application listen for notifications. I can issue a listen command using
std::string ourQuery = "LISTEN abc";
FdoPtr<FdoISQLDataReader> objSqlDataReader;
...blah...
objSqlDataReader = objSql->ExecuteReader();

But how would I receive a response from LISTEN? Would I have to periodically send ExecuteReader commands with a LISTEN query? Since LISTEN basically creates an event in the database, if I periodically call LISTEN abc, will it generate multiple events in the database or will it overwrite the previous event?

Since FdoISQLDataReader is meant for handling data coming from a database table column, how would I interpret the query returned from LISTEN (I'll be trying out some code for this in a few minutes, but the question in the above paragraph is troubling me)?
nav
Reply | Threaded
Open this post in threaded view
|

Re: How to listen for a Postgresql LISTEN?

nav
In reply to this post by zspitzer
Ok, I figured that multiple calls to LISTEN won't affect anything.
LISTEN registers the current session as a listener on the notification condition name. If the current session is already registered as a listener for this notification condition, nothing is done.

But I can't figure out how to get the return value of LISTEN in my C++ application. Can anyone help with this please?