question

Upvotes
Accepted
1 0 1 1

Not getting closure in the messages

Hey, I am registering the symbol with one thread but processing is happening in another thread. In this case I dont get the closure back which is precisely the ItemName.

elektronrefinitiv-realtimetreprfa
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.

Upvote
Accepted
30.2k 34 11 17

Hello @hamza.khalid,

Pass your closure as parameter into registerClient, per Developer Guide:

"... registerClient() on an OMM consumer or provider object. This method accepts

up to four parameters.

• The first parameter (pEventQueue) is a pointer to the event queue.

• The second parameter (ommItemIntSpec) is an interest specification.

• The third parameter (*this) is a client (i.e., the application callback that receives the dispatched events).

The fourth parameter is a closure, which is a pointer to some opaque data supplied by the application. For more information about closures, refer to Section 6.4.1.6...."

Hope this helps, however, if you are getting started with RFA C++, would suggest to first work through RFA C++ Quickstart and RFA C++ Consumer Tutorials to save you time, effort and usually improving on the overall learning experience.

If this is a new app, consider designing and implementing it with our latest API Suite Elektron, EMA C++ API.


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.

Hey,

I know how to use the API and the register client has 4 parameters I am sending closure as (void*) itemName. The problem is I am not receiving the closure back in the callback. Can you help me with that


Thanks

Hello @hamza.khalid,


In the framework of the discussion forum, when developers can have very different levels of familiarity with API, we try to answer any question in a way that will provide most help to the community. This is why I've discussed how to pass the closure.

This forum is designed for and can be most helpful for general questions and discussions centered around Refinitiv APIs.

The answer depends:

For me, the simplest way to make sure you are coding with Closure correctly, in my opinion, is to take a simple example that came with SDK (StarterConsumer, Consumer), single-threaded, pass closure on registerClient and confirm if you get it back properly in the callback.

If you do, then something else you do with threading is wrong, not the closure pass and retrieve.

If you don't, please include your specific registration code excerpt, we can take a look at how you are passing the closure. In the callback we can also take a look at the specific call, how you are retrieving the closure.

If rather you are looking for someone to be assigned and to take in-depth review of your code, that kind of requirement is not handled over discussions forum, but can be done over Premium Support channel. I could not find your organization on Premium support clients list, if I did not miss anything (sometimes it's under a different name after a re-org) and this is what you are looking to do, please discuss signing up for Premium Support with your Refinitiv account team.


Upvotes
30.2k 34 11 17

Hello @hamza.khalid,

You are correct, the intention with setting of Closure is to be able to receive it with received Events. And making requests from one Thread while receiving in another should not be a problem.

Can think of two things that may be helpful:

Section "Event Distribution Usage Guidelines" of RFA Developers Guide discusses good practices, as well as what not to do. Perhaps worth reviewing, and maybe you can come up with what you are doing wrong.

The other is ConsPerf that can be found in PerfTools folder of RFA SDK, it may be a good example to review, this is a threaded example built to test and tune performance, and registerClient is called from one thread, while processRespMsg is in another. It passes Closure of itemName. As a sanity check, I have just added printing Closure to processRespMsg (in different thread) and I see the closure printed as expected.

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.