FieldEntry name return doesn't match with the FieldValue

public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event) {
FieldList fieldList = updateMsg.payload().fieldList();
for (FieldEntry fieldEntry : fieldList)
{
if (Data.DataCode.BLANK == fieldEntry.code())
break;
else if (fieldEntry.fieldId() == fid)
fieldValue = Double.toString(fieldEntry.real().asDouble());
LOGGER.log(Level.INFO, "update~~~~~~~~" + updateMsg.name() + " " + fieldEntry.name() + " " + fieldValue);
break;
}
}

I am working on the implementation for the real time data to the excel plugin. I have encounter the following issue.

Here I have subscribe to the 0005.HKd with BEST_ASK1 and BEST_ASIZ1. I print out the update msg receive from data feed.

2019-08-28 16:04:52,896 - INFO : update~~~~~~~~0005.HKd BEST_ASK1 127600.0
2019-08-28 16:04:52,896 - INFO : update~~~~~~~~0005.HKd BEST_ASK1 56.05

The fieldEntry.name() return BEST_ASK1 instead of BEST_ASIZ1 for best ask size 1.

Best Answer

  • Hi @a33

    From the code, the updateMsg.name() and fieldEntry.real().asDouble() are not called in the same statement. Could you modify scope of else if statement to ensure that both interfaces are called at the same time as follows?

    public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event) 
    {
    FieldList fieldList = updateMsg.payload().fieldList();
    for (FieldEntry fieldEntry : fieldList)
    {
    if (Data.DataCode.BLANK == fieldEntry.code())
    break;
    else if (fieldEntry.fieldId() == fid)
    {
    fieldValue = Double.toString(fieldEntry.real().asDouble());
    LOGGER.log(Level.INFO, "update~~~~~~~~" + updateMsg.name() + " " + fieldEntry.name() + " " + fieldValue); break;
    }
    }
    }