How to read the MaxMessagesPerSecond element from an RCC RefreshMsg?

I have an EMA application that posts data to the RCC. As part of the connection sequence (register/tunnel/login) it receives a RefreshMsg like this:

RefreshMsg
    streamId="5"
    domain="System Domain"
    RefreshComplete
    PrivateStream
    DoNotCache
    state="Open / Ok / None / 'Login accepted by host 6805549f73b5 via ip-10-28-117-11.ec2.internal'"
    itemGroup="00 00"
    name="XXX"
    Attrib dataType="ElementList"
        ElementList
            ElementEntry name="TRCE:MaxMessagesPerSecond" dataType="UInt" value="10000"
        ElementListEnd
    AttribEnd
RefreshMsgEnd

I would like to read the MaxMessagesPerSecond value and use it for subsequent posting. I could parse it out of this text, but is there a way to way to access directly via the msg argument in code like that below:

(Note the pseudocode line that tries to set MsgLimit)

void AppClient::onRefreshMsg(const RefreshMsg& msg, const OmmConsumerEvent& event) {
   LOG_API.printf("%s\n%s\n", __FUNCTION__, msg.toString().c_str());
   if (msg.getDomainType() == MMT_SYSTEM
      && event.getHandle() == _subStreamHandle
      && msg.getState().getStreamState() == OmmState::OpenEnum
      && msg.getState().getDataState() == OmmState::OkEnum)
   {
      SetState(AS_loggedin);

// Get the message limit if present.
      UINT MsgLimit = msg.SomeFunction().someOtherFunction().etc()
   }
}


Tagged:

Best Answer

  • Jirapongse
    Answer ✓

    @jeff.birkel

    You can use the forth method to look for an element entry with the matching name, as shown below.

    const ElementList& el = refreshMsg.getAttrib().getElementList();
            if (el.forth("TRCE:MaxMessagesPerSecond")) {
                cout << el.getEntry().getName() << ":" << el.getEntry().getUInt();
            }