-
June 30th, 2010, 11:33 PM
#1
DataAdapter Service
Hi,
I've created a data adapter that is started with a bat file, and of course this works without any problems. So I decided to see how I could convert this to a windows service. Using VS2010, I created a class that inherits from the windows "ServiceBase" class. I also implement the Lightstreamer IDataProvider interface in this class. The problem I'm encountering is the ServiceBase implements their OnStart/OnStop methods while at the same time I need to implement the Lightstreamer Init method. I can get one set of methods called, but not the other. So in short I see the service starting, but the Init method is never called.
After viewing some other forum posts it would seem that this is a generic problem others are encountering. I'm seeing requests to have the Lightstreamer server to start it's data adapters or somehow have the adapters auto start. In a production environment I really don't see an admin having to remember to restart the adapters after a machine reboot/reconfiguration. Ideally the Lightstreamer server would have a configuration parameter that lists it's adapters for startup. I'm thinking most environments run their adapters on the same machine as the server - take a poll!
Thanks,
Bruce
-
July 1st, 2010, 04:09 PM
#2
A Remote Adapter can be launched in two ways:
- through the supplied DotNetServer_N2.exe, as shown in DOCS-SDKs\sdk_adapter_dotnet\examples\Remote_StockListD emo_Adapters\Deployment\Deployment_DotNet_Server;
- by writing a custom launcher, as shown in DOCS-SDKs\sdk_adapter_dotnet\examples\Remote_StockListD emo_Adapters\Deployment\Deployment_DotNet_Server(c ustom); examples, of custom launcher code are shown both in DOCS-SDKs\sdk_adapter_dotnet\examples\Remote_StockListD emo_Adapters\src_standalone_launcher and in the online tutorial.
The latter method allows you to add any kind of customization.
In your case, the onStart callback would replace the main method of the example code.
The call to the Start method on the DataProviderServer instance (actually triggered by the main method) in turn triggers the Init call on the IDataProvider instance.
About launching Remote Adapters by the Server itself, this can be achieved by customizing the supplied Proxy Adapters.
By wrapping the com.lightstreamer.adapters.remote.data.NetworkedDa taProvider (or RobustNetworkedDataProvider) class, you could hook the init method and launch the Remote Adapter there,
with any configuration parameters specified within the <data_provider> element in adapters.xml available.
By the way, note that the com.lightstreamer.adapters.remote.data.PipedDataPr ovider actually runs the Remote Adapter on the local machine, but this technique is not advised for production use.
-
July 2nd, 2010, 01:51 PM
#3
Hi Bruce,
Pardon my lack of knowledge on Windows Service implementation, but why can't you simply override the onStart method to implement the initialization of the Lightstreamer code?
Alessandro
-
October 14th, 2010, 11:22 PM
#4
Hi Alessandro,
Sorry I didn't reply sooner, but I was involved in another project. Anyway I revisited my code and found a solution. When the service is started, I have the main program instantiate the "service" instance. This causes the "OnStart" method to be called, this method in turn instantiates the class I call the "DataAdapterLauncher". This class was the piece I was missing. It has the DataProviderServer instance with the sockets setup and of course it wires up the instance I call "DataAdapter". The DataAdapter instance is implements the LightStreamer logic.
Now the only piece missing is something to wrap all this together. Since the Lightstreamer must be started "first", then the data adapters I was thinking I could write a service that starts the Lightstreamer service, wait for it to complete, then start the data adapter service.
Thanks,
Bruce
Similar Threads
-
By intelsmart in forum Adapter SDKs
Replies: 1
Last Post: April 11th, 2012, 09:03 AM
-
By msgiribabu in forum Adapter SDKs
Replies: 4
Last Post: February 3rd, 2011, 10:33 AM
-
By msgiribabu in forum Adapter SDKs
Replies: 1
Last Post: January 21st, 2011, 01:38 PM
-
By Irwin in forum Adapter SDKs
Replies: 11
Last Post: April 30th, 2010, 08:42 AM
-
By amarin in forum Adapter SDKs
Replies: 4
Last Post: August 21st, 2008, 09:23 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 06:13 AM.
Bookmarks