[Java Real-Time SDK] Performance issue while request instruments of a chain component

BMI
BMI Newcomer

Hello,

I would like your advice about performance issue while request instruments of a chain component.

For example, the chain 0#SRD.PA contains 144 instruments.

My algorythm opens one chain for SRD.PA (to retrieve its elements), and request each intruments to retrieve its quote informations :

protected RefinitivItem callChain(String ricId) {
FlatChain fChain = new FlatChain.Builder()
.withOmmConsumer(consumer.getConsumer())
.withChainName(ricId)
.withSynchronousMode()
.withUpdates(false)
.build();
fChain.open();

RefinitivItem item = new RefinitivItem(ricId, fChain);
for (Entry<Long, String> element : fChain.getElements().entrySet()) {
if (!element.getValue().isEmpty()) {
addFields(item, element);
}
}
fChain.close();
return item;
}

private void addFields(RefinitivItem item, Entry<Long, String> element) {
String elementRic = element.getValue();
RefinitivFields fields = callByRic(elementRic);
if (fields != null) {
item.addFields(element.getValue(), fields);
}
}

protected RefinitivFields callByRic(String ricId) {
RefinitivFields fields = null;
MarketPrice.Builder b = new MarketPrice.Builder().withOmmConsumer(consumer.getConsumer())
.withName(ricId)
.withUpdates(false)
.withSynchronousMode();
b.withField("REF_COUNT");
b.withField("RDNDISPLAY");
b.withField("RECORDTYPE");
b.withField("PREF_DISP");
b.withField("LOW_1");
b.withField("HIGH_1");
MarketPrice marketPrice = b.build();
marketPrice.open();

if (OmmState.DataState.OK == marketPrice.getState().dataState()
|| OmmState.DataState.NO_CHANGE == marketPrice.getState().dataState()) {
fields = new RefinitivFields(ricId, new ArrayList<>(marketPrice.getFields()));
}
marketPrice.close();

return fields;
}


Since openinig the request for one instrument lasts approximately 200 milliseconds, the call for the whole chain instruments lasts more than 30 seconds.

So my question is: am I doing it right ?

Best Answer

  • Gurpreet
    Gurpreet admin
    Answer ✓

    The Value add objects is for simplified access to the content - it is not geared towards performance. I would recommend that you initiate a batch request from the instruments in that chain.

Answers

  • Hi @BMI,

    30 seconds is a very long time - are you connecting to a remote endpoint? Typically, for a local RTDS, your batch request should be fulfilled in few 100 milliseconds. I would recommend that you try the same request with an EMA batch example and compare.

    You can modify the batch example which is packaged with the SDK - https://github.com/Refinitiv/Real-Time-SDK/tree/master/Java/Ema/Examples/src/main/java/com/refinitiv/ema/examples/training/consumer/series300/ex370_MP_Batch


  • BMI
    BMI Newcomer

    Hi @Gurpreet,

    Thank you for your answer.

    I am connecting to a remote endpoint, with Delivery Direct.

    Here is a piece of my EmaConfig.xml file :

    Channel

    <ChannelGroup>
    <ChannelList>
    <Channel>
    <Name value="Channel_1"/>
    <ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
    <CompressionType value="CompressionType::None"/>
    <GuaranteedOutputBuffers value="5000"/>
    <ConnectionPingTimeout value="30000"/>
    <EncryptedProtocolType value="EncryptedProtocolType::RSSL_SOCKET"/>
    <Host value="eu-west-1-aws-3-lrg.optimized-pricing-api.refinitiv.biz"/>
    <Port value="14002"/>
    <EnableSessionManagement value="1"/>
    <WsProtocols value="tr_json2"/>
    </Channel>
    </ChannelList>
    </ChannelGroup>

    Dictionary

    <DictionaryGroup>
    <DictionaryList>
    <Dictionary>
    <Name value="Dictionary_1"/>
    <DictionaryType value="DictionaryType::ChannelDictionary"/>
    </Dictionary>
    </DictionaryList>
    </DictionaryGroup>


    I tried the batch example, and performances are much better.

    But in my case, I have to display all the instruments' quotations from the chain, so I request EMA synchronously.

    For that, I use the ValueAddObjectsForEMA example library.

    I noticed that when calling the MarketPrice.open method, a Thread.sleep(200) is performed in the library.

    At first, I tried to reduce this waiting time. It's faster, but the instruments are still requested synchronously.

    Maybe I should try to request all the instruments asynchronously, and wait for all quotation informations to be retrieved, then compute the result for the presentation layer ?