question

Upvotes
Accepted
37 14 18 18

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

refinitiv-realtimeelektrontreprfajava
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
1.9k 7 11 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 512.0 KiB each and 1.0 MiB total.

Thanks for the detailed info @Nipat Kunvutipongsak.

Upvotes
32.2k 41 11 20

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

Thanks @zoya.farberov.

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.