Logging ReqMsg using EMA API

thimalk
thimalk Explorer
I have the following code to log the ReqMsg to stdout but application will get crash with segmentation fault in the cout line.

Can't we use ReqMsg like this. If not what is the way to log the ReqMsg.

try {
AppClient client;
OmmConsumer consumer( OmmConsumerConfig().host( "localhost:14002" ).username( "user" ) );
ReqMsg reqMsg;
reqMsg.serviceName("DIRECT_FEED").name("IBM.N");
cout << reqMsg << endl;
consumer.registerClient( reqMsg, client );
sleep( 60000 );// API calls onRefreshMsg(), onUpdateMsg(), or onStatusMsg()
} catch ( const OmmException& excp ) {
cout << excp << endl;
}

Best Answer

  • umer.nalla
    umer.nalla LSEG
    Answer ✓
    @thimalk

    EMA C++ does not allow the decoding of partially encoded messages.

    If you are trying to debug your app, then you can enable low level tracing as follows:

    In your EmaConfig.xml you can add the XmlTraceToFile parameter for the Channel that you wish to enable Xml Trace for.

    e.g.

    <Channel>
    <Name value="Channel_1"/>
    <ChannelType value="ChannelType::RSSL_SOCKET"/>
    <CompressionType value="CompressionType::None"/>
    <GuaranteedOutputBuffers value="5000"/>
    <Host value="10.13.225.38"/>
    <Port value="14002"/>
    <XmlTraceToFile value="1"/>
    </Channel>

    The above should enable trace of request and response messages - default filename is 'EmaTrace'.
    Please refer to section 3.2.2 of the EmaCPP_ConfigGuide.pdf for details on this and other XmlTrace related parameters.

    Section 4.4.3 also illustrates an example that sets this value using Programmatic config (rather than EmaConfig.xml).

    Regards,

    Umer