question

Upvotes
Accepted
26 3 7 11

Error: Login Stream closed with msg : Text: Received ChannelUp event on channel Channel_1 Instance Name Consumer_1_1 Component Version upa7.6.0.L1.win.rrg 64-bit Static

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)

refinitiv-realtimeelektronelektron-sdkema-apirrtelektron-message-api
screenshot-2.png (37.1 KiB)
screenshot-1.png (12.4 KiB)
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
25.4k 90 13 25

Hi @rkumar

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:

  • to dispatch any incoming events - so that the relevant event callback handlers (onRefresh, onUpdate etc) can be invoked to process those events
  • The 60s timed loop also ensures that your main application thread does not exit immediately. If you dont loop for a while and exit the application as soon as you call registerClient then how can the application receive any events and therefore data back from the server?

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.

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.

I had this doubt , i read about dispatch() method and it says "Relinquishes application thread of control to receive callbacks via OmmConsumerClient descendant" so in that case why do i need while loop when the dispatch method itself is relinquishing (exiting) my application thread of control and taking control in its own hand. i think my streams should stay open and i should keep receiving callbacks in AppClient even tho i dont use while loop. Is it correct what i supposing , can i receive callbacks forever without using while loop ??

Hi @rkumar

The dispatch method is what is responsible for your client receiving callbacks. When an event is dispatched, the corresponding event handler is invoked.

So, as I mentioned previously, if you do not continue to dispatch - how will your application continue to receive callbacks as and when new events arise (e.g. new data / status msg etc)

If you do not wish to perform the dispatching yourself then you can use the default API_DISPATCH mechanism which is what most of the other series 100 examples (e.g example120) use.

Please read this section of the EMA Java Dev Guide for details.

Upvotes
25.4k 90 13 25

Hi @rkumar

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?

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.

@Umer Nalla First of all i do not get what is the use of that while loop and second i do not want my application thread to sleep when i want data for multiple item at runtime. How can i do it ? is there any mechanism to run separate thread for every stream or open every stream on one single thread apart from application thread ? and what is the use of (long argument ) type constructor of dispatch() method ??

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.