RFA.NET - Seperate threads - event dispatching and event processing
Hi,
As part of using RFA.Net in order to get market price information, we implemented:
QueueDispatcher which runs in the background in thread and do
eventQueue.Dispatch();
In the other hand we created EventClient implemented Client interface, and use it in the interest registration (registrations are in stream mode).
My question: As it seems in debug, the dispatching (i.e. QueueDispatcher) and the event processing made by the same thread. Due to large number of Rics I'm a little bit worry about that and I'd like to know if - is there a way to seperate the Event processing thread from the dispatching thread?
Best Answer
-
Basically, if an Event becomes available following a call to Dispatch(), RFA invokes the Client callback method specified when opening the Event Stream. Thus the event processing made by the same thread.
If your concern is the scenario that it has a large number of Rics or high update rate, you might need to clone the event and then put it in your own queue and process the Event in other thread. Basically, event objects are only valid within the function context of the Event Handler function call (i.e., ProcessEvent()). Once the application returns from ProcessEvent() the Event object is no longer valid. If the application wishes to asynchronously process the Event it will need to make its own copy for later processing by using the Clone() method.
An application may create a copy of an Event by using the Clone() method while in the Client callback method. Unlike the Event provided in the Client callback method, the application is responsible for cleaning up a cloned Event via the Event’s Destroy() method. Note that a Clone() call makes a heap allocation and may affect performance.
Also using Horizontal Scaling feature may help in this case. When Horizontal Scaling enables RFA applications to use multiple instances of the Consumer on multi-core processors to dynamically scale the number of Session instances that applications use. Since each instance of a horizontally-scaled adapter processes messages on its own connection (independently of other adapter instances),
applications can utilize this feature to dramatically increase Response Message and Request Message throughput.
You can find more details about Horizontal Scaling from RFA Developer Guide section Horizontal Scaling.0
Answers
-
Thanks for your reponse. One more question regarding it: If we'll stay with the current implementation (means one thread for dispatching and processing). In case of the heavy event processing "blocks" the eventQueue.Dispatch(); what will happen with the awaits events? There will be a bottle-nack? Or there is some sophisticated mechanism which care of sending just the freshests events? For our business needs, we don't need every update. It will be fair enough to get some of them per minute/second.
Thanks!
0 -
Yes, there will be a bottle-neck. If you have a time-consuming task in the processEvent callback, the first issue is memory growth issue because there are a lot of events left in the event queue. The second issue is that the data the application layer receives is delayed due to the bottleneck.
Instead of sending streaming request, you may need to send a snapshot request or a snapshot request+view(to selected only fields you interest) every minute or sec.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 690 Datastream
- 1.4K DSS
- 629 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 559 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 24 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 279 Open PermID
- 45 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 713 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 106 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 95 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛