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 ?




Best Answer

  • 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)