CallBacks using java

Hello,

Am build a TREP RFA component and wondering if you could help with example of using CallBacks in Java. Presently, I can successful consume the data using the eventQueue.dispatch method and have the output printed out.

Ideally, I would want the output from consuming from TREP to be sent to another application or just an output from a function.

Any advise or example would be much appreciated.

Thanks

Best Answer

  • Hello @josa ,

    We can also refer to 'Callbacks' concept as 'Asynchronous Communication'.

    RFA Java provides an interface named 'Client' which has an abstract method named 'processEvent()'. When the application wants to subscribe to an item, it has to call OMMConsumer.registerClient() method by specifying a derived class of 'Client' as one of the arguments.

    When the RFA underlying layer receives data from a server, RFA will call the registered processEvent() callback method. Therefore, you can put your logic in the overridden processEvent() of the derived class of the 'Client' interface.

    As you can see, after the application registered the item subscription, it doesn't have to wait for a response and it can perform any other jobs after the registration. Any further incoming data/messages will come through the processEvent() method when they arrive.

Answers