question

Upvotes
Accepted
3 0 1 6

Unconditional Consumer API or stops when no msgs to consume?

Please clarify with below code snippet, when the consumer stops consuming the data from ADS? The reason for this question would be, it consumes the market data continuously when I comment out the finally block below but stops consuming when there is a finally block. I understand the use of finally here but on the other side is what I'm trying to. Does consumer stops whenever there is no update message or there is any configuration concept to understand behind it? On what time out basis does consumer continue to consume the data when there is no finally block? Any lights on this would be great to understand better.

batch.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));
batch.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, view_data_array));

consumer.registerClient(EmaFactory.createReqMsg().serviceName("FINANCE_PRICES").payload(batch), appClient);
Thread.sleep(60000);    // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg()
} catch (InterruptedException | OmmException excp) // views last_traded limit the consumer resp
{
 LOG.info(excp.getMessage());
} finally {
    if (consumer != null) consumer.uninitialize();
}



#technologyjavasnapshot-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.

@Aalim

Hi,

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

Upvotes
Accepted
79.2k 251 52 74

@mohammedsardarmca

Thank you for reaching out to us.

After the consumer can connect and login to the server, the consumer will maintain a connection to the server. As long as the connection is alive, the API can consume data from the server.

To stop consuming data from the application, the application needs to cut the connection by uninitializing the consumer or exiting the application.


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.

Ok, Thank you. If we don't uninitialise the consumer forever, say I commented out the finally block, is there any time limitation for the provider quit due to over usage? If no, what's the concept it works behind? What architecture does this work behind? Curious to know about that ever running thread.


Also, I remember read some where around the EMA is not thread safe! So, what kind of multi thread safety code should I make while consuming from EMA? Any thoughts on this may help here.

Upvotes
79.2k 251 52 74

@Aalim

It is similar to file handling in an application.

As long as a file is opened, an application can read and write from/to that file. Finally, an application needs to close a file to release the resouces and free the memory. This also covers socket programming.

consumer.uninitialize() is used to close the connection, release the resources, and free the memory.

Regarding the thread safety, as far as I know, EMA is thread safe. Please let me which document that mentions that EMA is not thread safe. I will contact the product team to verify it.


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.

It was documented in one of my internal portal. Would you bother referring me the right document to ensure EMA thread safe and it will be awesome to read?

@Aalim

It was mentioned in the ETA developer guide in section 2.3 Performance and Feature Comparison.

1707446012127.png

Please also update the document in the internal portal to avoid any further confusions.

1707446012127.png (49.2 KiB)

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.