Exception Type='OmmInvalidUsageException' when using fixedWidth in view Array

marian
marian Newcomer

Most likely something primitive, but I wanted to check our understanding:

when creating a view I thought it was a good practice to set the array size as fixed. It looks as if this is triggering an Exception OmmInvalidUsageException.

Please see below is an example of a simple snapshot request using a view array. Is this normal?

AppClient client; OmmConsumer consumer(OmmConsumerConfig().username("user")); 

//Symbols
OmmArray symbolArray;
{
symbolArray.addAscii("EUR=");
symbolArray.complete();
}
//Fields
std::vector<thomsonreuters::ema::access::Int64> fields{11,12,13,22,25};
OmmArray viewArray;
//viewArray.fixedWidth(static_cast<thomsonreuters::ema::access::UInt16>(fields.size())); //With this line we are getting
//"Exception Type='OmmInvalidUsageException', Text='Unsupported fixedWidth encoding in addInt(). Fixed width='5'. '""
//If commented out everything seems to work fine. Is it normal?
for (auto f : fields)
{
viewArray.addInt(f);
}
viewArray.complete();
ElementList elemList;
elemList.addArray(thomsonreuters::ema::rdm::ENAME_BATCH_ITEM_LIST, symbolArray);
elemList.addUInt(thomsonreuters::ema::rdm::ENAME_VIEW_TYPE, 1);
elemList.addArray(thomsonreuters::ema::rdm::ENAME_VIEW_DATA, viewArray);
elemList.complete();
ReqMsg test;
//Just a snapshot
consumer.registerClient(ReqMsg().serviceName("hEDD").interestAfterRefresh(false).payload(elemList), client);

Best Answer

  • warat.boonyanit
    Answer ✓

    Hi @marian

    fixedWidth() is not for the size of the array but for the length of each content inside.

    By using fixedWidth(X) you basically define that content inside the array cannot be bigger than X bytes.

    fixedWidth() is used for decoding optimization and can be omitted.

    Edit: "each content"

Answers