Can I simulate the reuters to send item messages to my own application?

There's some problems happend in my application, can I simulate the reuters to send item messages to debug to find reasons?

Best Answer

  • Dear @Raj.Huang,

    The easy way to send a STATUS message with NO_DATA is to use a simple example named IProvider (in package com.thomsonreuters.ema.examples.training.iprovider.series100.example100__MarketPrice__Streaming).

    In this example, you need to modify the source code to send a STATUS message to downstream:

    Original Code:
    for( int i = 0; i < 60; i++ )
    {
    fieldList.clear();
    fieldList.add(EmaFactory.createFieldEntry().real(22, 3991 + i, OmmReal.MagnitudeType.EXPONENT_NEG_2));
    fieldList.add(EmaFactory.createFieldEntry().real(30, 10 + i, OmmReal.MagnitudeType.EXPONENT_0));

    provider.submit( EmaFactory.createUpdateMsg().payload( fieldList ), appClient.itemHandle );

    Thread.sleep(1000);
    }

    Modified Code:
    // To publish data forever instead of 60 second.
    for( int i = 0; true; i++ )
    {
    if (i != 0 && i%10 == 0) {
    provider.submit( EmaFactory.createStatusMsg(), appClient.itemHandle );
    } else {
    fieldList.clear();
    fieldList.add(EmaFactory.createFieldEntry().real(22, 3991 + i, OmmReal.MagnitudeType.EXPONENT_NEG_2));
    fieldList.add(EmaFactory.createFieldEntry().real(30, 10 + i, OmmReal.MagnitudeType.EXPONENT_0));

    provider.submit( EmaFactory.createUpdateMsg().payload( fieldList ), appClient.itemHandle );
    }
    Thread.sleep(1000);
    }

    Also, you need to modify OmmIProviderImpl.java to avoid NullPointerException as well (see the code below):

    Original Code:

    void handleItemInfo(int domainType, long handle, State state )
    {
    if ( state != null && state.streamState() != StreamStates.OPEN )
    {
    ItemInfo itemInfo = getItemInfo(handle);
    ...

    Modified Code:

    void handleItemInfo(int domainType, long handle, State state )
    {

    // Add a logic to check null reference
    if ( state != null && state.streamState() != StreamStates.OPEN )
    {
    ItemInfo itemInfo = getItemInfo(handle);
    ...

    Then, you can run the example such as a Consumer application in com.thomsonreuters.ema.examples.training.consumer.series100.example100__MarketPrice__Streaming package to connect to this provider application. Here this is the excerpt result:

    <!-- Incoming Reactor message -->
    <!-- java.nio.channels.SocketChannel[connected local=/127.0.0.1:13933 remote=localhost/127.0.0.1:14002] -->
    <!-- Wed Sep 27 17:40:55 ICT 2017 -->
    <!-- rwfMajorVer="14" rwfMinorVer="1" -->
    <UPDATE domainType="MARKET_PRICE" streamId="3" containerType="FIELD_LIST" flags="0x00" updateType="0" dataSize="15">
    <dataBody>
    <fieldList flags="0x08 (HAS_STANDARD_DATA)">
    <fieldEntry fieldId="22" data="0C14 BE"/>
    <fieldEntry fieldId="30" data="0E05 31"/>
    </fieldList>
    </dataBody>
    </UPDATE>

    <!-- Incoming Reactor message -->
    <!-- java.nio.channels.SocketChannel[connected local=/127.0.0.1:13933 remote=localhost/127.0.0.1:14002] -->
    <!-- Wed Sep 27 17:40:56 ICT 2017 -->
    <!-- rwfMajorVer="14" rwfMinorVer="1" -->
    <STATUS domainType="MARKET_PRICE" streamId="3" containerType="NO_DATA" flags="0x00" dataSize="0">
    <dataBody>
    </dataBody>
    </STATUS>

    <!-- Incoming Reactor message -->
    <!-- java.nio.channels.SocketChannel[connected local=/127.0.0.1:13933 remote=localhost/127.0.0.1:14002] -->
    <!-- Wed Sep 27 17:40:57 ICT 2017 -->
    <!-- rwfMajorVer="14" rwfMinorVer="1" -->
    <UPDATE domainType="MARKET_PRICE" streamId="3" containerType="FIELD_LIST" flags="0x00" updateType="0" dataSize="15">
    <dataBody>
    <fieldList flags="0x08 (HAS_STANDARD_DATA)">
    <fieldEntry fieldId="22" data="0C14 C0"/>
    <fieldEntry fieldId="30" data="0E05 33"/>
    </fieldList>
    </dataBody>
    </UPDATE>

    Note that the IProvider example will exit immediately if you disconnect the consumer application from the provider. You need to restart IProvider to perform simulation again.

    Hope this helps!

Answers