question

Upvotes
Accepted
1 0 1 1

RFA.NET Snapshot - Synchonous

Hi,

I am trying to understand what is the most efficient way to do snapshots using RFA.NET

I am looking at the example Examples\OrderBookAndMarketPriceBag\OrderBookAndMarketPriceBag. In the MarketPriceWrapper class, there is a method to call Snapshot but it seems to be asynchronous.

1. Can we have an example of how to call snapshot in a synchronous way?
2. Is there a way to know that a snapshot is completed?
3. Is there any timeout we can put so if it takes too long, then we cancel the snapshot request?
4. If snapshot is incomplete, is there a way to know what data is missing?

Thanks!

treprfarfa-apisnapshot-pricingsynchronous
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
120 3 4 7

Hi

In RFA a Snapshot is just a flag set in the request, it means we want only initial refresh message (not the updates), all the remaining code is the same.

You can 'emulate' a synchronous request using a method where you make a loop calling eventQueue dispatch, for instance:

// send Snapshot request

...

reqMsg.InteractionType = ReqMsg.InteractionTypeFlag.InitialImage;

handle = Context.OMMConsumer.RegisterClient(Context.EventQueue, ommItemIntSpec, this, closurel);

// wait data for 'timeoutSeconds'

                    System.DateTime currentTime = System.DateTime.Now;
                    System.DateTime endTime = currentTime.AddSeconds(timeoutSeconds);
                    receivedSnap = false;
                    while ((!receivedSnap) && (currentTime < endTime))
                    {
                        eventQueue.Dispatch(dispatchTimeOutInterval);
                        currentTime = System.DateTime.Now;
                    }

Somewhere in your processEvent() when the snap is receivede you set receiveSna=true.


	public void ProcessEvent(Event evnt)
        {
            switch (evnt.Type)
            {
                case SessionLayerEventTypeEnum.OMMItemEvent:
                    // extract event data
			receivedSnap = true;

                    break;
                default:
                    break;
            }
        }


In a scenario with multiple request you will need maybe a Dictionary to store the receivedSnap flag for each request. (you can use the closure parameter to help identify from which ric the refresh refers to, etc).



It would be inefficient to request and wait each ric image at a time.

Paulo.
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
1 0 1 1

Thanks - I will need to look into more details the dispatch method and also dispatchTimeOutInterval parameter. In our case, we have indeed multiple request - up to 800 Rics for a snapshot. So I am trying to find the most efficient way to do so.

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.