PDA

View Full Version : Non-blocking IDataProvider.Subscribe


bartol82
08-29-2011, 05:32 PM
Hi,

We are in a process of refactoring our current .NET data adapter which will change the current synchronous (blocking) implementation of the IDataProvider.Subscribe method with an asynchronous (non-blocking) one.

As the LS docs say that a non-blocking Subscribe method is recommended, how should we handle invalid subscription requests which will now be queued and handled in a different thread than the one that called Subscribe ? (currently we throw a SubscriptionException in the Subscribe method)

Thanks

DarioCrivelli
08-30-2011, 11:15 AM
The recommendation for a non-blocking implementation of Subscribe is made for the java adapter interface, on which the Data Adapter runs in-process with the Server.
For remote Data Adapter the requirement on Subscribe (http://www.lightstreamer.com/docs/adapter_dotnet_doc/Lightstreamer_Interfaces_Data_IDataProvider_Subscribe@string.html) has been relieved (you may have found a stronger one for older versions of the .NET adapter interface).
Anyway, in order to invoke Subscribe, Lightstreamer library needs to spawn a thread for each call (and to enqueue calls for the same item). So, if you can find a way to keep the invoking thread busy for a short time, this should be beneficial.

Actually, sending a SubscriptionException is not very different from just not sending updates, as the information is not forwarded to the clients. By sending a SubscriptionException you mainly avoid to receive a redundand Unsubscribe.
So, if you defer the management of Subscribe, you should not have problems.