question

Upvotes
Accepted
5 1 2 6

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-sdkema-apirrt
icon clock
10 |1500

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

1 Answer

· Write an Answer
Upvotes
Accepted
25.3k 87 12 25

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 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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