As subject, my application need to continuously retrieve price from TREP for 7x24.
By referring the reply in a similar question, I tried using Channel and specifying ConnectionPingTimeout, but seems doesn't work, the session still end once after receiving price.
I can't find any similar case in official sample also.
Should I use dead loop or long time thread sleep after registerClient() to keep the connection alive?
Any code or sample for my refer?
Much appreciated for any suggestion!
An EMA Java consumer application can be as long running, as you prefer, and only exit on specific criteria or condition specified by you, such as requested exit.
I suspect that you are asking, because our example consumers that come with Elektron SDK are targeted to 1 minute runs.
The do so by exiting from the main thread, 1 minute after the initial registration similar to this:
consumer.registerClient(reqMsg.serviceName("ELEKTRON_EDGE").name("IBM.N"), appClient); Thread.sleep(60000);
if this is right, you can keep the main thread going any way that is consistent with your requirements, for example
consumer.registerClient(reqMsg.serviceName("ELEKTRON_EDGE").name("IBM.N"), appClient); while (no_stop_requested == true) Thread.sleep(1000)
Please let us know, if this helps, or you are asking about something different, in which case, please be more descriptive on what session end you are referring to?
It is based on your application design and requirement. If you choose to suspend a connection, you can use the API Pause/Resume feature during that 2 hours break. The API will keep a connection with TREP but pause all items subscriptions on that time.
You can find EMA Java Pause/Resume example in EMA Java example 350_MarketPrice_PauseAll example.
In my opinion, if application is suspended for several days, pause/resume may not suitable because item remains open and is still in the ADS Cache. The ADS continues to receive messages from its upstream device (or feed) and updates the item in its cache (but because of the client‟s pause request, does not send new data to the client). For more details, please refer to 3.2.4 Pause and Resume in Elektron API Concepts Guide