How to judge Msg(StatusMsg. UpdateMsg. RefreshMsg) is codeChain or quotation

luxiangyuan
luxiangyuan Contributor

Hi:

I request the codeChain and stock in one process;

When i get Msg in onRefreshMsg or onUpdateMsg, How i can decide the msg is codeChain or quotation?

thanks

Best Answer

  • Hello @luxiangyuan

    Another way is to set closure in OmmConsumer.registerClient(ReqMsg reqMsg,OmmConsumerClient client,java.lang.Object closure) method when the application subscribes a RIC. closure parameter is used to specify application-defined item identification. Hence, in onRefreshMsg(..) or onUpdateMsg(..), you can check OmmConsumerEvent's closure if it is for which RICs or group of RICs(codeChain or quotation) before decoding data.

    For example:

    //for codeChain RIC 

    consumer.registerClient( EmaFactory.createReqMsg().serviceName("ELEKTRON").name("0#.DJI"), appClient, "codeChain");


    //for quotation RIC

    consumer.registerClient( EmaFactory.createReqMsg().serviceName("ELEKTRON").name("JPY="), appClient, "quotation");

    and in onRefreshMsg(..) , onUpdateMsg(..)

    public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) 
    {
    if(event.closure().toString().equalsIgnoreCase("codeChain"))
    {
    System.out.println("process codeChain");
    ....
    }
    else if(event.closure().toString().equalsIgnoreCase("quotation"))
    {
    System.out.println("process quotation");
    ...
    }
    }

    The example result:

    When the application receives data of codeChain

    image

    When the application receives data of quotation

    image

Answers