question

Upvotes
Accepted
2 0 2 2

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 );
elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
Accepted
23k 22 9 14

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

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
20.3k 73 10 20

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 );
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
2 0 2 2

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() );
}


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

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.

Click below to post an Idea Post Idea