rajesh.palanisamy
Hi
we are taking the snapshot data for an item from multiple rest Api calls
so we are thinking to call endodsnapshot after each api call is made. Is that recommended, will it have any impacts on the ls server.
Say item1 subscription,
api -1 success , call end of snapshot
api-2 success , call end of snapshot
etc
our doubt is whether it will impact multiple clients in any manner.
I’m not understanding the term discarded information, what msged will be discarded??
After that an unsubscribe call for the Item has returned, further calls of this method for the itemHandler received with the last subscription operation are still allowed and will be just discarded.
thanks
rajesh
Giuseppe Corti
Hi Rajesh,
I can confirm that only the first endOfSnapshot for each Item makes sense for the server.
All subsequent ones are simply ignored, apart from a possible annoying message in the log.
Also from a client point of view only the first EOS is significant, all the others are in no way affecting the data flow towards the client.
About last question, the documentation refer to the case when a Data Adapter still use an itemHandler to push updates after the unsubscribe method was called.
In that specific case no errors would be generated but simply the updates are ignored.
Regards,
Giuseppe
rajesh.palanisamy
Thanks Giuseppe for the reply,
I have another question in command mode subscription mode,
Consider my data feed is from DB/REST call,
In subscribe method data retrieval fails for client 1, because of datasource DB/REST API server issue.
After some time client 2 connects, in this scenario i am noticing that subscribe method is never called untill there are atleast one active subscription for that item.
Here the scenario is the snapshot data is not sent to server from feed, so the consecutive client connections must some how trigger the subscribe method or data retrieval logic to give the data.
How to mitigate this call, i tried throwing the SubscriptionException,FailureException but i am not seeing any effect. There is no call made to adapter upon second connection.
Thanks
Rajesh
Giuseppe Corti
Hi Rajesh,
The SubscriptionException informs the server that the item is considered failed, and just as in the case of success the subscribe method will no longer be called until at least one active client keeps a subscription for that Item.
I think that the best practice to cope with such a scenario is that once the Data Adapter determines that the item name is valid, but an external service fails is to return succesfully the subscribe method an start a background task polling the external service at regular intervals.
If an unbsubscribe will be called before you got a reply from the external service the task will be cancelled.
Otherwise, if you want to avoid the background task, you should let communicate the Metadata Adapter with the Data Adapter, and replace the subsequent subscribe calls with the notifyNewTable calls.
Regards,
Giuseppe
rajesh.palanisamy
HI Giuseppe,
Thanks for the quick reply,
I am going for the second option - communication between metaData and data adapter.
Is there a direct way to trigger the subscribe method of data adapter from notifyNewTable call, i could see Demos with volatile attributes which trigger the data pull for each item. Apart from that do you have any other recommendation for the communication.
Thanks
Rajesh
Giuseppe Corti
Hi Rajesh,
Yes you are right, the most convenient solution, especially in case of Java adapters, is that the Metadata holds a reference to the Data Provider instance, and perform direct calls when needed.
That said, please consider also the possibility that the Metadata call not the subscribe method but a different method in order to distinguish the two cases, the regular subscribe call from the Lightstreamer server, from Metadata incoming calls.
Regards,
Giuseppe
rajesh.palanisamy
Thanks Giuseppe its acknowledged, I will make sure we have different method calls.
One question, is it possible to use spring Application events for metaData and data adapter communications? Implement ApplicationListener<ApplicationEvent> in our DATA Adapters so we can fire an application event from metaDataAdapter once notifyNewTables is called.
To put in simple words,
can we initialize spring context inside adapter life cycle classes ?
Thanks
Rajesh
Dario Crivelli
Hello Rajesh, We don't have direct experience with this specific integration to share, but in principle we don't pose any restriction on what you can put in the adapters.
However, the Adapters are loaded in dedicated ClassLoaders and this should be taken into account.
See the "classloader" elements in adapters.xml.
To have the Data and Metadata Adapter see each other, it is enough that you stick to the default configuration.
In this case, a single ClassLoader loads everything in the "lib" subdirectory and is used to load both adapters.
In this way, also any external library that you put in the common "lib" subdirectory is visible from both adapters.
The same ClassLoader is also set as the "context ClassLoader" in all invocations to the adapters.
You should ensure that the library doesn't have additional requirements that are not compatible with this structure.
It may also be important to consider the order in which the Adapters are loaded and initialized.
By leveraging the <metadata_adapter_initialised_first> element in adapters.xml you can ensure that the load and initialization of the Metadata Adapter is the first entry point in your code.