unsubscribe an active subscription

zoe
zoe LSEG
edited November 2024 in EMA

  1. What is the appropriate way to determine if the session is connected or disconnected from OmmConsumerEvent?

void EmaSession::onStatusMsg(const StatusMsg &statusMsg, const OmmConsumerEvent &event)

  1. Also, what is the appropriate way to unsubscribe an active subscription?

How can we unregister with the handle return in register?

// register
UInt64 handle = mConsumer->registerClient(emaReq, *this);
// handle =140239205235712
 
onUpdateMsg {
mConsumer->unregister(event.getParentHandle()); //140239205235712
// Caught OmmException: Invalid attempt to close batch stream. Instance name='consumer1_2'.
 
mConsumer->unregister(event.getHandle()); // 1402434320535765
// Work fine
}

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @zoe

    Thank you for reaching out to us.

    1. You need to register to get the login events. Please refer to the 330_Login_Streaming. Then, you need to call the OmmConsumerEvent::getChannelInformation() of the login stream to get the ChannelInformation. Next, call the ChannelInformation::getChannelState to get the ChannelState.

      image.png
    2. For a batch request, you need to call mConsumer->unregister(event.getHandle()) of an item stream to unregister an item handle. It was mentioned on the Reference Guide that for batch request items, the getParentHandle() method returns the item identifier of the top level batch request.