question

Upvotes
Accepted
22k 58 14 21

What is a "closure" in RFA?

rfa
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
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 512.0 KiB each and 1.0 MiB total.

Upvotes
24.6k 54 17 14

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 512.0 KiB each and 1.0 MiB total.

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

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.