29 2 4 4

How do I read in data from a non-TREP source in order to post to TRCC?

Hello, This goes back to my original question where I asked how to replace an application which contributed data to Reuters via MLIPs. I was pointed to using EMA Consumer with posting. I have successfully been able to connect to a test TRCC and post a test message using 'EMA Consumer - Posting data to TR Contribution Channel' sample program.

My question now is, how do I feed in non-TREP based data to be posted. The previous MLIP oriented application received data via a direct socket connection to a source which uses a different message protocol. Can this be done using EMA? How do I tap into the main loop of a EMA Consumer application.

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.


Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?

If so please can you click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question.



1 Answer

· Write an Answer
25.3k 87 12 25

Hi @efreeman

Am I right in assuming that you referring to the TRCC tutorial as a basis for your new implementation?

If so, you will note that in that example, once you get a MMT_SYSTEM RefreshMsg with the subStreamHandle (which was registered in the onUpdateMsg method) then the example sends out the first Post:

if (refreshMsg.getDomainType() == MMT_SYSTEM &&
            event.getHandle() == _subStreamHandle &&
            refreshMsg.getState().getStreamState() == OmmState::OpenEnum &&
            refreshMsg.getState().getDataState() == OmmState::OkEnum)

After that, once it receives an Ack for the above Post, it continues to send out Update Post messages.

The above is done is this way as it is a purely educational example.

For a real life implementation such as yours, once you get back that initial MMT_SYSTEM Refresh with the subStreamHandle, you can start sending out Post Messages as and when required based on your implementation requirements.

In the above example the main application thread sends the MMT_LOGIN and then just sleeps for several minutes - to allow the example to login, create the substream and send several post messages (all done via the callbacks on the API thread) before finally exiting.

So, instead of sleeping the main thread, you could wait on an indicator flag - which you would set when above RefreshMsg has been received. Once the indicator flag has been set, you can start posting from the main thread as and when required.

You could also look at example 130_MarketPrice_UserDisp which lets you control the dispatching of the events rather than letting the API dispatch the events (behind the scenes) as with the TRCC example.

unsigned long long startTime = getCurrentTime();
while ( startTime + 60000 > getCurrentTime() )
    consumer.dispatch( 10 );        // calls to onRefreshMsg(), onUpdateMsg(), or onStatusMsg() execute on this thread

So, with the above implementation - in addition to calling dispatch, you could add your additional control code to the same while loop e.g. waiting for the Substream to be established and then sending your Posts as and when required. The key thing is to keep calling dispatch to ensure the the API continues to process events/message between your application and the server.

You can read more about Dispatching etc in the EMACPP_DevGuide.pdf which comes with the Elektron SDK and can be found in the ema\docs subfolder.

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.