question

Upvotes
Accepted
15 2 5 12

Better way to build a database of Snapshot values for a list of RICs using EMA api

Hi,

I have a requirement that I need to create a database of snapshot values for a list of RICs in a given interval say 15 minutes.

I have the below code that runs for every 15 minutes and it did the job.

OmmConsumer consumer = EmaFactory.createOmmConsumer(config);
ElementList ricBatch = EmaFactory.createElementList();
ricBatch.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_BATCH_ITEM_LIST, ommArray));

//Specify Dynamic view of fields
ricBatch.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));
ricBatch.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, fields));

ReqMsg ricReqMsg = EmaFactory.createReqMsg().serviceName(adsService).payload(ricBatch) .interestAfterRefresh(false);
consumer.registerClient(ricReqMsg, this);
//wait for snapshot request to be fulfilled
consumer.uninitialize();


Obviously I see that EMA API creates a new consumer thread with new ads connection for each of the snapshot call.

Is there a better do this , that optimized the resources and reuses the connection to ADS server ?

Thanks in advance

Mani

refinitiv-realtimeema-apijavasnapshot-pricing
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.

Upvotes
Accepted
79.8k 257 52 75

@Mani.A

Instead of creating a new OMMConsumer every 15 minutes, you can reuse it.

You can create an OMMConsumer when the program starts.

OmmConsumer consumer = EmaFactory.createOmmConsumer(config);

Then, call the consumer.uninitialize() method when the program exits.

consumer.uninitialize();

Next, call the consumer.registerClient(ricReqMsg, this) method every interval to get snapshots.

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.

Upvotes
25.3k 89 12 25

Hi @Mani.A

Also, just to be clear - you don't need to create a separate OmmConsume for each ReqMsg that you register - same OMMConsumer instance can be used to make multiple batch requests if required.

I only mentioned this because I have come across a few developers who did not realise this and were creating an OmmConsumer for each batch request.

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.

Upvotes
15 2 5 12

Thanks @Jirapongse and @umer.nalla

It worked. Earlier I tried reusing the OmmConsumer but made a mistake calling the OmmConsumer.uninitialize() at the end of each iteration instead of at the end of the program.

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.