Item Resubscription

So we open a session for subscription for an item say AAPL.OQ, get some refresh and updates, then close the subscription using CloseMsg with below params:

closeMsg.clear();
encodeIterator.clear();
closeMsg.msgClass(MsgClasses.CLOSE);
closeMsg.containerType(DataTypes.NO_DATA);
closeMsg.flags(CloseMsgFlags.ACK);
byteBuffer.clear();
encodeBuffer.clear();
encodeBuffer.data(byteBuffer);

encodeIterator.setBufferAndRWFVersion(encodeBuffer, Codec.majorVersion(), Codec.minorVersion());

Now within the same session, I want to resubscribe to AAPL.OQ, I see that though my request for subscription is sent to TREP, I don't get any responses (refresh messages) back.

How to resubscribe after unsubscription within the same session

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @pratik.p.mehta

    To close a stream, you need to specify the streamID of the closed item.

    closeMsg.clear();
    closeMsg.msgClass(MsgClasses.CLOSE);
    closeMsg.streamId(streamId());
    closeMsg.domainType(domainType);
    closeMsg.containerType(DataTypes.NO_DATA);

    After that, you can send a new request message to subscribe to that item.

    You can refer to the com.thomsonreuters.upa.examples.consumer example in the Elektron SDK package regarding closing and requesting items.

Answers

  • Hi @pratik.p.mehta

    Depending on your use case / requirements - you may want to explore the Pause / Resume functionality available with the Elektron APIs.

    As the name suggests, you can pause an event stream and resume it as required - for some scenarios this can be more efficient than close and resubscribe.