If I subscribe to "IBM.N" for example via:
UInt64 IBMhandle = pConsumer->registerClient( ReqMsg().serviceName( "ELEKTRON_DD" ).name( "IBM.N"), *this );
Is there no way to tie the event back to the RIC name other than the handle?
For example:
void AppClient::onRefreshMsg( const RefreshMsg& refreshMsg, const OmmConsumerEvent& event) { if(event.getHandle() == IBMhandle) { cout << "I have an update for IBM!!!" << endl ; } if (DataType::FieldListEnum == refreshMsg.getPayload().getDataType()) decode(refreshMsg.getPayload().getFieldList()); }
Is there no way to get the RIC name directly from the event?
Hi @jtalvy
If you want the instrument name, have you looked at another consumer example e.g. Consumer120 - 120__MarketPrice__FieldListWalk?
Both the onRefresh() and onUpdate() dump the name of the item using the getName() method
void AppClient::onRefreshMsg( const RefreshMsg& refreshMsg, const OmmConsumerEvent& ) { if ( refreshMsg.hasName() ) cout << endl << "Item Name: " << refreshMsg.getName(); ..... } void AppClient::onUpdateMsg( const UpdateMsg& updateMsg, const OmmConsumerEvent& ) { if ( updateMsg.hasName() ) cout << endl << "Item Name: " << updateMsg.getName(); .... }
You can also consider using Closures - please see the post Example of closure in EMA
In the post above it uses simple descriptors for the closure, a more realistic usage could be to pass in your local application level object that represents the instrument as the closure and then get back a reference to the object in the callback event.
OR you could just pass in the RIC as the closure....
EMA library keeps a Map behind the scenes between Handles and data items names. Using this, it is able to inject the data item name into the messages so that is looks as if it was received from the wire (it is not!). So Umar's answer will work just fine. EMA is "developer convenient" in this respect. (as opposed to the underlying API, called ETA, where you have to take care of this yourself but also have more control)
@jtalvy. Apologies. I made assumptions based on what I know from ETA, not EMA. I've updated my answer. You are not increasing network traffic. (but there is in fact a feature where you can ask the server side to send the information with each and every UPDATE message and using that feature will increase network traffic, but what EMA does it actually to simulate that feature)
EMA CPP - Exception adding ric into OmmArray
Has RIC 1RTYM1m been changed to RTYM1m
(JAVA) Does using interestAfterRefresh(false) remove the need for deregistering items with Elektron?
How do you identify if a RIC is a chain RIC in order to subscribe to all the underlying RICs?
How can I find Non-deliverable Forward RIC for BRL, CLP, COP, IDR, KRW, MYR, PEN, PHP, RUB, VND ?