question

Upvotes
Accepted
5 0 0 3

Does EMA Msg object is parsing thread safe ?

Hi guys,

We are working with EMA API.


For better performance, we only use OmmConsumer API Thread to dispatch Msg object.


Then put it in queue and the Msg object will be parsed in other thread.


However, when we parsing the Msg object, we found the data was corrupted and got many ConcurrentModificationException.


So we wonder whether the Msg object is thread safe ?


If not, dose it mean the only way to get better performance is create more OmmConsumer ?




elektronrefinitiv-realtimeelektron-sdkrrtema-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.

1 Answer

Upvotes
Accepted
20.3k 73 10 20

Hi @pengshuolin

The EMA objects such as Msg is owned by the EMA thread - once the callback (e.g. OnRefresh, OnUpdate) returns you cannot access the Msg safely - it may have been destroyed by the EMA thread.

To access the Msg outside the callback, you must clone the msg e.g EMA Java.

public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event)
{
    UpdateMsg clonedUpdMsg = EmaFactory.createUpdateMsg(updateMsg);
    // store / pass clonedUpdMsg for use in other thread..
    //......
    return;
}

For EMA C++, you can create a new instance of the message - copying the EMA instance

refinitiv::ema::access::UpdateMsg::UpdateMsg(const UpdateMsg & other) 
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.

Click below to post an Idea Post Idea