i want to request data at runtime and i am using USER_DISPATCH operation model. i am referring example130__MarketPrice__UserDisp. but when i am removing below code and trying to access data for the first time i get following logs as in (screenshot-1.png) and stream gets closed.
long startTime = System.currentTimeMillis(); while (startTime + 60000 > System.currentTimeMillis())
but when i add above two lines of code then my code runs perfectly for first time as well as i am able to request data for second item while stream is still fetching data for first item but at last when stream for both data items gets closed i get following error as in (SCREENSHOT 2)
If you have not already done so, I strongly recommend you work through the first few steps of the EMA Java tutorials so that you can gain a better understanding of how EMA works.
Briefly, the while loop in that particular example serves two purposes:
Just to be clear, EMA data consumption is asynchronous - i.e. the API sends the request to the server when you call registerClient and the server then responds asynchronously at some time in the future - initially with a Refresh, follows by Updates as & when there is appropriate market activity.
You don't need separate threads for each item - most EMA developers can handle several thousand instruments with the one thread and one OmmConsumer instance. Developers typically introduce multiple threads (+OmmConsumer instances) when they are consuming tens of thousands of instruments.
The long timeout parameter is how many milliseconds the dispatch method waits for a new event to arrive before returning.If an event arrives before the timeout it will dispatch the event immediately and return.
Can you please advise why you are removing the mentioned lines of code? And also what you are replacing it with? If you remove the loop - how are you ensuring the application continues to dispatch the events that are received from the server (and does not just terminate after calling dispatch once)?
Also, it is not entirely clear what you mean by 'as well as i am able to request data for second item while stream is still fetching data for first item but at last when stream for both data items gets closed i get following error'
Can you please expand on how / when the streams for the data items are close?