Alerter

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tnx
Posts: 10
Joined: Mon 16 Mar 2009 17:52

Alerter

Post by tnx » Thu 18 Jun 2009 18:21

Hi,

In PostgresDAC, there was an option to listen to all events that the session is has registered using the LISTEN command.

So I could simply have an alerter, and register the events using a LISTEN command in some PlPgSQL function exactly where I would like to start listening.

With PgDAC, I cannot just use the LISTEN command alone in my own SQL statement but I have to use the TPgAlerter.Event, which is a comma delimited string that I have to maintain. When I make changes to that string, I have to Stop and re-Start the alerter...

Can there be an option to listen to everything - so I could control what I want to listen to using LISTEN and UNLISTEN statements elsewhere, without having to touch the TPgAlerter on the client-side.

Thanks

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 23 Jun 2009 07:14

TPgAlerter uses separate connection to listen events. So LISTEN and UNLISTEN commands do not affect the alerter.

You can use the OnNotification event of TPgConnection instead of TPgAlerter. This event occurs when notification comes on the main connection. Note: OnNotification event can occur only after you execute some query or other server operation. The server sends a notification in response to a query.

tnx
Posts: 10
Joined: Mon 16 Mar 2009 17:52

Post by tnx » Sun 05 Jul 2009 19:22

Well, PostgresDAC can manage this somehow. Why do you open a new connection if this is not necessary?
Is it possible to have the option that PostgresDAC offers? Polling isn't an option. That's not the point of having notifications.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 06 Jul 2009 13:36

Alerter can get notifications in two ways:
1. Listen the connection all the time, and read notifications when they became available on the connection. This method requires the connection to be used by the alerter only. Other components cannot use this connection. This method is used by TPgAlerter.

2. Use the timer, and execute a query on the connection periodically. Notifications are received as response to the query. This way is used by the alerter in PostgresDAC. You can emulate this method in the following way: place TTimer component on the form and execute a query in the OnTimer event.

Post Reply