TPgAlerter
TPgAlerter
Hello,
I am using a TPgAlerter component. I create a TPgConnection object and assign the TPgAlerter components connection property to it. When I activate the TPgAlerter, I see in the PostgreSQL statistics that this TPgAlerter component actually connects to the PostgreSQL database TWICE. So it creates two connections.
Is this normal ? I dont want it to use two connections, that seems excessive.
Is there anything I can do to change this behaviour ?
I am using a TPgAlerter component. I create a TPgConnection object and assign the TPgAlerter components connection property to it. When I activate the TPgAlerter, I see in the PostgreSQL statistics that this TPgAlerter component actually connects to the PostgreSQL database TWICE. So it creates two connections.
Is this normal ? I dont want it to use two connections, that seems excessive.
Is there anything I can do to change this behaviour ?
Re: TPgAlerter
PgDAC uses a separate PostgreSQL connection instance to handle alerts. Therefore, you see two connections on the PostgreSQL side. One of them is main and the second - a service one for alerts. This is correct behavior.
When calling the TPGAlerter.Start method, PgDAC checks whether the TPgConnection instance has a separate service connection for alerts and, if not, creates it. For example, if PGAlerter1, PGAlerter2, PGAlerter3 are bound to the PgConnection1 instance, all these three TPGAlerter instances will use the same service connection of the PgConnection1 instance.
When calling the TPGAlerter.Start method, PgDAC checks whether the TPgConnection instance has a separate service connection for alerts and, if not, creates it. For example, if PGAlerter1, PGAlerter2, PGAlerter3 are bound to the PgConnection1 instance, all these three TPGAlerter instances will use the same service connection of the PgConnection1 instance.
Re: TPgAlerter
I understand what you are saying, thanks for the explanation.
So in my application, I have a main connection (used for application logic), let's call this one connection A.
For the TPgAlerter, I create a new connection B, which I attach to the TPgAlerter component. I do NOT use this connection for anything, it is just tied to the TPgAlerter component.
This results in THREE connection being made to PostgreSQL (one for A and two for B).
If I do not create a separate connection (B) for the TPgAlerter component, but just connect my main connection A to it, would that be OK ? This should result in only two connection being made to the DB, right ? Would this influence my main connection in any way ? I do not want the main connection A to be influenced...
Would this be OK ?
So in my application, I have a main connection (used for application logic), let's call this one connection A.
For the TPgAlerter, I create a new connection B, which I attach to the TPgAlerter component. I do NOT use this connection for anything, it is just tied to the TPgAlerter component.
This results in THREE connection being made to PostgreSQL (one for A and two for B).
If I do not create a separate connection (B) for the TPgAlerter component, but just connect my main connection A to it, would that be OK ? This should result in only two connection being made to the DB, right ? Would this influence my main connection in any way ? I do not want the main connection A to be influenced...
Would this be OK ?
Re: TPgAlerter
Exactly this way we recommend doing.
Exactly. When calling the TPgConnection.Connect method, A will create one database connection. It will be used for user SQL queries. When calling TPGAlerter.Start, A will create the second database connection. It is used only for alerts.
Alert connection is isolated from the user level. Thus, you can be sure that an alert connection A won't influence a main connection A and vice versa.
Re: TPgAlerter
Ah, that's great, thanks !
Is there a way I can set the 'ApplicationName' property of the alert-connection (Options.ApplicationName property of the TPgConnection class) without changing it for the main connection A as well ? We monitor connections so we can see what's going on, and this way we can recognize them.
Is there a way I can set the 'ApplicationName' property of the alert-connection (Options.ApplicationName property of the TPgConnection class) without changing it for the main connection A as well ? We monitor connections so we can see what's going on, and this way we can recognize them.
Re: TPgAlerter
In PgDAC, there is no possibility to set the alert connection parameters, since it is isolated from the user. All alert connection parameters are taken from the main connection, including TPgConnection.Options.ApplicationName . However, you can find out the PID of the main connection from the TPgConnection.ProcessID property .
Re: TPgAlerter
We'll do that. Thanks for the help!
Re: TPgAlerter
Thank you for the interest to our product.
Feel free to contact us if you have any further questions about our products.
Feel free to contact us if you have any further questions about our products.