question

Upvotes
Accepted
22 7 9 11

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

elektronrefinitiv-realtimetreprfajava
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
1.9k 6 9 16

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.

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 for the detailed info @Nipat Kunvutipongsak.

Upvotes
23k 22 9 14

Hello @josa,

This is not JRFA specific, thinking that perhaps you will find the following JavaWorld article useful:

Implement callback routines in Java

Or the following answer from StackOverflow:

How do I perform a JAVA callback between classes?

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 @zoya.farberov.

Click below to post an Idea Post Idea