EMAJ: How to keep a long connection in OMMConsumer like 7x24

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!

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • zoya faberov
    zoya faberov ✭✭✭✭✭
    Answer ✓

    Hi @loy.longyi,

    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?

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.