java如何在FAST协议中解码序列
我对快速消息中的序列有一些问题
例如,我有下一个模板xml
<template name="DefaultIncrementalRefreshMessage" id="1">
<string name="ApplVerID" id="1128">
<constant value="9"/>
</string>
<string name="MessageType" id="35">
<constant value="X"/>
</string>
<string name="SenderCompID" id="49">
<constant value="MOEX"/>
</string>
<uInt32 name="MsgSeqNum" id="34"/>
<uInt64 name="SendingTime" id="52"/>
<uInt32 name="LastFragment" id="893" presence="optional"/>
<sequence name="MDEntries">
<length name="NoMDEntries" id="268"/>
<uInt32 name="MDUpdateAction" id="279"/>
<string name="MDEntryType" id="269"/>
<uInt64 name="SecurityID" id="48" presence="optional"/>
<uInt32 name="SecurityIDSource" id="22">
<constant value="8"/>
</uInt32>
<string name="Symbol" id="55" presence="optional"/>
<string name="SecurityGroup" id="1151" presence="optional"/>
<uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
<uInt32 name="RptSeq" id="83"/>
<uInt32 name="MarketDepth" id="264" presence="optional"/>
<uInt32 name="MDPriceLevel" id="1023" presence="optional"/>
<int64 name="MDEntryID" id="278" presence="optional"/>
<decimal name="MDEntryPx" id="270" presence="optional"/>
<int64 name="MDEntrySize" id="271" presence="optional"/>
<uInt32 name="MDEntryDate" id="272" presence="optional"/>
<uInt32 name="MDEntryTime" id="273"/>
<int32 name="NumberOfOrders" id="346" presence="optional"/>
<string name="MDEntryTradeType" id="20003" presence="optional"/>
<int32 name="TrdType" id="828" presence="optional"/>
<decimal name="LastPx" id="31" presence="optional"/>
<int32 name="MDFlags" id="20017" presence="optional"/>
<string name="Currency" id="15" presence="optional"/>
<uInt64 name="Revision" id="20018" presence="optional"/>
<string name="OrderSide" id="10504" presence="optional"/>
</sequence>
</template>
首先我得到模板的PMap,下一步我得到模板id,然后我一个接一个地读取字节,所有工作正常,但是如果我得到序列'MDEntries',我的数据将不正确,因为字节序列将被破坏。
我看到了下一张具有快速消息结构的图片,认为我应该读取序列和长度为“NoMDEntries”的PMap,然后逐个读取字节,对吗?我曾经认为我应该一个接一个地读取字节并删除停止位
请帮助我,如何正确解析“序列”
# 1 楼答案
根据FAST协议规范,如果序列中没有需要PMap位存在的字段(如您的情况),那么PMap不应该出现在流中。 要了解字段是否需要PMap位,可以使用下表:
您可以参考本文件第10.5段和附录3.3.1:http://ftp.moex.com/pub/FAST/ASTS/docs/FAST%20Specification1_1.pdf