For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
5 2 2 3

How to get Webscoket MarketPrice updates based on delay(5 sec for example) and not constant updates.

Hello, We have used your Java based Websocket MarketPrice batch example. It is working fine and we are getting updates continuously without any delay. However if we want to add a delay lets say of 5 seconds, then how can we do it. Now we are constantly receiving updates through websocket.

We need to add the rates in database but not too fast, atleast with delay of 5 seconds. Please assist where to mention the delay for this websocket based example to receive RIC updates in every 5 sec.

treprdp-apiwebsocketsrrto
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
23.5k 84 10 22

Hi @amar.a.panigrahi

If you are using an in house TREP system, you can ask your Market Data team to setup a Conflated service for you which can limit updates to the configured interval period.

Otherwise, you could implement conflation logic at your application level, to limit how often your write to your database i.e. apply any updates to an application level representation for each RIC and then flush the object values to the database every 5 seconds if any values have changed.

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.

What if we sleep the WebSocketAdapter Listener for 5 seconds in onTextMessage callback. We tried it, its working but don't know the impact. Will the latest update messages will be discarded by the Listener thread? We need to update the rates in database so continuous update without breadth is making the system slow. So please let us know if adding sleep in listener is one of the correct way to do it?

Upvotes
28.3k 30 11 15

Hi @amar.a.panigrahi,

Absolutely agree with @Umer Nalla, conflated service would be the most efficient way.

As another option, one can request a snapshot request, every 5 seconds, for example:

{
  "ID": 2,
  "Key": {
    "Name": "MSFT.O"
  },
  "Streaming": false
}
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.

So, adding streaming=false, will give us the updates with a delay? and where should we specify the delay?

Specifying non streaming request will give you only one image response, which you will have to snap again, every 5 seconds. A better approach is to have the service conflate the streaming updates at source.

Upvotes
5 2 2 3

@Umer Nalla @zoya.farberov

What if we sleep the WebSocketAdapter Listener for 5 seconds in onTextMessage callback. We tried it, its working but don't know the impact. Will the latest update messages will be discarded by the Listener thread? We need to update the rates in database so continuous update without breadth is making the system slow. So please let us know if adding sleep in listener is one of the correct way to do it?

And if not the above, as @zoya.farberov suggested doing streaming=false will help.

So it will gives us the delayed rates. Where can we specify the the delay?
suggestred

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
14.7k 39 12 18

Sleeping in the callback is not recommended as, it does not slow down the incoming updates, but will queue them in an internal buffer instead. So after 1 minute, your application will be getting data which is 1 minute old, and after a while application might crash, due to memory overrun.

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.