Search code examples
quickfixj

QuickFIX/J: Unable to fetch the field from FIX message, although I can see its value


I am unable to fetch the field 6610 from my request and get an error field is not found. I am using quickfix 2.1.1 library. Please help.

private KeyContext extractKeyContext(MarketDataRequest marketDataRequest) throws FieldNotFound {
        LOGGER.info("Inside extractKeyContext()");
        KeyContext keyContext = null;
        try {
            LOGGER.info("Inside extractKeyContext() with MarketDataRequest: {}", marketDataRequest);
            // request logged here is : 8=FIX.4.4__9=202__35=V__34=2__43=Y__49=K9__52=20240212-10:08:32.647__56=dh-dev__122=20240212-10:08:32.601__142=192.200.8.84__262=18271FFFFFFFF60E70616__263=1__146=1__55=GHJ__65=DRT__271=1__6610=3M__10=250__

            StringField time = (StringField) marketDataRequest.getField(new StringField(6610));
            LOGGER.info("time [{}]", time);
            
        } catch (Exception e) {
            LOGGER.error("Error while extracting keyContext:[{}],[{}],[{}]", e.getMessage(), e.getCause(), e.getStackTrace());

        }
        LOGGER.info("Inside extractKeyContext() - extracted keyContext [{}]", keyContext);
        return keyContext;
    }

Error:
Error while extracting keyContext:[Field was not found in message, field=6610],[null],[[quickfix.FieldMap.getField(FieldMap.java)


<message name="MarketDataRequest" msgtype="V" msgcat="app">
            <field name="MDReqID" required="Y" /> <!--262-->
            <field name="SubscriptionRequestType" required="Y" /><!--263-->
            <group name="NoRelatedSym" required="N"> <!-- Required in Subscription 146 -->
                <field name="Symbol" required="Y" /> <!--55-->
                <field name="SymbolSfx" required="N" /> <!--65-->
                <field name="SettlDate" required="N" /> <!--64-->
                <field name="MSize" required="N" /><!--271-->
                <field name="Time" required="N" /><!--6610-->
            </group>
        </message>

Solution

  • You need to access the group to get the field. See https://www.quickfixj.org/usermanual/2.3.0/usage/repeating_groups.html

    MarketDataRequest.NoRelatedSym group = new MarketDataRequest.NoRelatedSym();
    FieldMap fieldMap = marketDataRequest.getGroup( 1, group );
    fieldMap.getString(6610);