question

Upvotes
Accepted
13k 32 12 18

What is a "closure" in RFA?

rfa
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
426 2 4 4

Closure is used in RFA registerCllient() method to pass any application specific data to the processEvent() callback function. For example, we need to know the item name of a update event in order to apply the update data to the application data. However, Item name is only available in the AttributInfo object which is usuallyanly available in the Refresh event. Update events do not have AttributInfo unless requested specifically. We can pass the Item name when we subscribe the item:

Handle itemHandle = _mainApp.getOMMConsumer().registerClient(_mainApp.getEventQueue(),   ommItemIntSpec, this, itemName);

In ProcessEvent(), simply call getClosure() method to retrieve the itemName:

OMMItemEvent ie = (OMMItemEvent)event;
String _ric = (String) ie.getClosure();
System.out.println("ItemName:" + _ric);
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
11.5k 16 7 10

Regarding the RFA Developer Guide, the closure object is a application-defined use. An application may supply a closure object on sending an Interest Specification. RFA returns the Closure in Events. A closure is a reference to an object supplied by the application.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thanks, but why is it needed. Is it mandatory for requesting market data.

Click below to post an Idea Post Idea