TMSChangeNotification and subscription timeout message

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Rnest
Posts: 10
Joined: Fri 19 Oct 2007 14:45

TMSChangeNotification and subscription timeout message

Post by Rnest » Thu 24 Jan 2013 14:49

In my project I'm using TMSChangeNotification component to reflect changes in my SQL tables. In some situations (eg. app error), SQLBroker queues are orphanded, hanging on server. Then, after next run of application, message "The subscription timeout expired" is displayed. How to avoid/hide/handle this message?

AndreyZ

Re: TMSChangeNotification and subscription timeout message

Post by AndreyZ » Fri 25 Jan 2013 11:40

Hello,

For each notification that is sent by SQL Server, the TMSChangeNotification.OnChange event is called. But, SDAC does not show any messages about notifications. Please make sure that you do not show them in the TMSChangeNotification.OnChange event handler.

Rnest
Posts: 10
Joined: Fri 19 Oct 2007 14:45

Re: TMSChangeNotification and subscription timeout message

Post by Rnest » Fri 25 Jan 2013 13:04

OnChange event handler is null in this project.
In this case it may be message forced by sqlNativeClient library (?) so maybe there is any way to handle it, eg by making some tweaks in SDAC Library sources?

AndreyZ

Re: TMSChangeNotification and subscription timeout message

Post by AndreyZ » Mon 28 Jan 2013 14:38

Please specify the exact version of SQL Server server and client. You can learn it from the Info sheet of TMSConnection Editor.

Rnest
Posts: 10
Joined: Fri 19 Oct 2007 14:45

Re: TMSChangeNotification and subscription timeout message

Post by Rnest » Wed 30 Jan 2013 09:19

SQL Server version: 10.50.1600
NativeClient: 10.52.4000.0

AndreyZ

Re: TMSChangeNotification and subscription timeout message

Post by AndreyZ » Wed 30 Jan 2013 13:29

I cannot reproduce the problem. Please try creating a small sample to demonstrate the problem and send it to andreyz*devart*com .

Rnest
Posts: 10
Joined: Fri 19 Oct 2007 14:45

Re: TMSChangeNotification and subscription timeout message

Post by Rnest » Wed 30 Jan 2013 15:40

OK, message sent.

AndreyZ

Re: TMSChangeNotification and subscription timeout message

Post by AndreyZ » Thu 31 Jan 2013 09:30

I have reproduced the problem. It occurs if the TMSQuery.Options.ReflectChangeNotify property is set to True. It means that TMSQuery will refresh itself on receiving notifications about data modifications. In this case, exceptions that may occur are handled by the Application.HandleException method. If you want to catch such exceptions, you should create your own exception handler method and set Application.OnException to it. Here is a code example:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnException := MyOnException;
end;

procedure TForm1.MyOnException(Sender: TObject; E: Exception);
begin
  // your code that handles exceptions
end;

Rnest
Posts: 10
Joined: Fri 19 Oct 2007 14:45

Re: TMSChangeNotification and subscription timeout message

Post by Rnest » Thu 31 Jan 2013 13:29

Thank you very much. This is the best solution and resolves the problem, especially when combined with TMSNotification.OnChange event handler.

AndreyZ

Re: TMSChangeNotification and subscription timeout message

Post by AndreyZ » Fri 01 Feb 2013 08:00

I am glad I could help. If any other questions come up, please do not hesitate to contact us.

Post Reply