Fail safe connection

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

Fail safe connection

Post by tnx » Sat 21 Mar 2009 15:34

Hello

I need a way to find out that a PgDac connection is/was down. Unfortunately, what I am currently experiencing this is that after short network connection loss, the next query raises an exception (Socket error on read / Socket error on write) and in case of protocoll pv20, all further queries raise an exception.

I don't see the OnConnectionLost working and my alerters are not re-registered after a reconnect even with AutoRegister.

I have basically no way of finding out that a reconnect happened. I need to be notified about this event and re-register events and call some application-specific initialization queries.

How do I build a bullet-proof application with PgDac?

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

Post by Plash » Mon 23 Mar 2009 08:56

You can use the AfterConnect event of TPgConnection to execute your initialization queries. The AutoRegister property of TPgAlerter does not support the automatic reconnect of PgDAC. You should start alerters manually in the AfterConnect event.

The OnConnectionLost event can be fired only if you set the LocalFailover option of TPgConnection to True. In this case the reconnect is smarter, and can be performed without rasing an exception to the user.
See the 'Using PgDAC / Working in an Unstable Network' topic in the PgDAC help for more information about the LocalFailover feature.

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

Post by tnx » Tue 24 Mar 2009 13:55

Thank you. I will try that.

Post Reply