beginner question: unsubscribe from a RIC

I am sorry if this is too basic but I do not see it in the examples or docs I was provided.

I can subscribe to a RIC.... but once I am done with it how do I unsubscribe?

I subscribe via:

thomsonreuters::ema::access::OmmConsumer *pConsumer
pConsumer->registerClient( ReqMsg().serviceName( "ELEKTRON_DD" ).name( RicName ), *this );

Best Answer

  • zoya faberov
    Answer ✓

    Hello @jtalvy,

    If all you need is a snapshot, a better way would be to register interest:

    consumer.registerClient( ReqMsg().serviceName( "ELEKTRON_DD" ).name( "IBM.N" ).interestAfterRefresh( false ) , client );

    Please refer to Consumer examples that came with EMA C++ SDK, Consumer 101, Snapshot

Answers

  • Hi @jtalvy

    Please see example 300_MarketPrice_Close

    _pOmmConsumer->unregister( ommEvent.getHandle() );

    The above is called from the onUpdateMsg() callback handler - so it has easy access to the handle of the item stream it wants to close.

    If you want to close the item stream from a point where you don't have an event related to the particular item, then you will need to store the handles e.g. in a lookup table or inside any structure or class you may be using to represent the item within your application.

    The handle is returned when you first call registerClient e.g.

    UInt64 handle = pConsumer->registerClient( ReqMsg().serviceName( "ELEKTRON_DD" ).name( RicName ), *this );
  • Great thx! If I just need a snapshot I will do:

    void AppClient::onRefreshMsg( const RefreshMsg& refreshMsg, const OmmConsumerEvent& event)
    {
    if (DataType::FieldListEnum == refreshMsg.getPayload().getDataType())
    decode(refreshMsg.getPayload().getFieldList());
    pConsumer->unregister( event.getHandle() );
    }


  • Hi @jtalvy,

    To perform a snapshot, you simply specify that your request is non-streaming. That is:

    UInt64 handle = pConsumer->registerClient( ReqMsg().serviceName( "ELEKTRON_DD" ).name( RicName ).interestAfterRefresh(false), *this );

    By doing this, you will only receive the initial image and the stream will automatically close. You can refer to example 102_MarketPrice_Snapshot.