How to encode msgKey attribute in RFA Java

RFA Java provides the OMMAttribInfo.getAttrib() method, but not setAttrib() method. What should I do to set the Attrib to OMMAttribInfo object?

Tagged:

Best Answer

  • @Catherine Wong

    According to the document (<RFA_PACKAGE>/Docs/refman/rfajava/com/reuters/rfa/omm/OMMEncoder.html), if the application wants to encode attrib, it must not specify the second parameter as OMMTypes.NO_DATA.

    encodeMsgInit
    void encodeMsgInit(OMMMsg msg,
    short attibDataType,
    short dataType)

    OMMMsg encoding initialization


    Parameters:

    msg - the message to be encoded.

    attibDataType - the data type that is contained in the OMMAttribInfo. OMMTypes.NO_DATA if encoded OMMAttribInfo will not contain OMMData (i.e. OMMAttribInfo.getAttrib()).

    dataType - the data type that is contained in the message. OMMTypes.NO_DATA if encoded message will not contain data.

    Referring to RFA Java RDM Usage guide, OMMAttribInfo.Attrib is not used in most of domains except a Login domain.

    Since the RFA example applications usually manage the administrative domain (Login, Source Directory, and Dictionary) automatically, you can find the simple demonstration from a LoginClient.encodeLoginReqMsg() method of a StarterConsumer example.

    Please see the snippet code below:

        private OMMMsg encodeLoginReqMsg()
    {
    OMMEncoder encoder = _mainApp.getEncoder();
    OMMPool pool = _mainApp.getPool();
    encoder.initialize(OMMTypes.MSG, 500);
    OMMMsg msg = pool.acquireMsg();
    msg.setMsgType(OMMMsg.MsgType.REQUEST);
    msg.setMsgModelType(RDMMsgTypes.LOGIN);
    msg.setIndicationFlags(OMMMsg.Indication.REFRESH);
    msg.setAttribInfo(null, CommandLine.variable("user"), RDMUser.NameType.USER_NAME);


    encoder.encodeMsgInit(msg, OMMTypes.ELEMENT_LIST, OMMTypes.NO_DATA);
    encoder.encodeElementListInit(OMMElementList.HAS_STANDARD_DATA, (short)0, (short)0);
    encoder.encodeElementEntryInit(RDMUser.Attrib.ApplicationId, OMMTypes.ASCII_STRING);
    encoder.encodeString(CommandLine.variable("application"), OMMTypes.ASCII_STRING);
    encoder.encodeElementEntryInit(RDMUser.Attrib.Position, OMMTypes.ASCII_STRING);
    encoder.encodeString(CommandLine.variable("position"), OMMTypes.ASCII_STRING);
    encoder.encodeElementEntryInit(RDMUser.Attrib.Role, OMMTypes.UINT);
    encoder.encodeUInt((long)RDMUser.Role.CONSUMER);
    encoder.encodeAggregateComplete();


    // Get the encoded message from the encoder
    OMMMsg encMsg = (OMMMsg)encoder.getEncodedObject();


    // Release the message that own by the application
    pool.releaseMsg(msg);


    return encMsg; // return the encoded message
    }

    Below is an application log:

    MESSAGE
    Msg Type: MsgType.REQUEST
    Msg Model Type: LOGIN
    Indication Flags: REFRESH
    Hint Flags: HAS_ATTRIB_INFO
    AttribInfo
    Name: U0154418
    NameType: 1 (USER_NAME)
    Attrib
    ELEMENT_LIST
    ELEMENT_ENTRY ApplicationId: 256
    ELEMENT_ENTRY Position: 10.42.85.159/U0154418-TPL-A
    ELEMENT_ENTRY Role: 0
    Payload: None

    Hope this helps!

Answers

  • zoya faberov
    zoya faberov ✭✭✭✭✭

    In RFA Java 8 kit, please see framework => provider => DictionaryStreamItem:

    ...

    OMMAttribInfo attribInfo = pool.acquireAttribInfo();

    attribInfo.setServiceName(_dictMgr.getServiceName());

    attribInfo.setName(_name);

    attribInfo.setFilter(filter); // Specifies all of the normally needed


    // data will be sent.


    msg.setAttribInfo(attribInfo);

    enc.encodeMsgInit(msg, OMMTypes.NO_DATA, OMMTypes.SERIES); // Data is

    ...
  • @zoya.farbefov

    Thanks, but if I just want to add ElementList in the msgKey too? How can I set it to OMMAttribInfo object. It provides setFilter(), setId(), setName(), setNameType(), setServiceID() and setServiceName() only.

  • zoya faberov
    zoya faberov ✭✭✭✭✭

    I think you are looking to encode ElementList into message itself ( you are writing a provider) as OMMAttribInfo is designed to provide optional attributes/hints.

    Please see in reference OMMEncoder for specifics on how to encode and complete on OMMData, OMMEelemntList is OMMData.

    Please see example of Series encoding in provider => DictionaryStreamItem, it is the same approach.

  • It looks like what I want. I can attach some parameters in msg.Attrib along with the request message.

    MESSAGE
    Msg Type: MsgType.REQUEST
    Msg Model Type: Unknown Msg Model Type: 254
    Indication Flags: REFRESH
    Hint Flags: HAS_ATTRIB_INFO | HAS_QOS_REQ
    QosReq: (RT, TbT)
    AttribInfo
    ServiceId: 1
    Name: CW_TEST_CUSTOM_RIC
    NameType: 1
    Attrib
    ELEMENT_LIST
    ELEMENT_ENTRY startDate: 01/01/2016
    ELEMENT_ENTRY stopDate: 25/02/2016
    ELEMENT_ENTRY threshold: 3
    Payload: None