FIX.5.0SP2 Message
Heartbeat [type '0']
The Heartbeat monitors the status of the communication link and identifies when the last of a string of messages was not received.
心跳消息实现:
cs.mina.codec.msg; java.util.HashSet; java.util.List; java.util.Set; cs.mina.exception.InValidDataException; BaseMsg { request; Tag testReqID Tag(,,); Set tagIdsSet HashSet(); HeartbeatMsg(){ .getHeadEntity().getMsgType().setTagValue(); tagIdsSet.add(); .bodyEntity.getBodyTagList().add(testReqID); } validate() { .headEntity.validate(); ListTag bodyTagList.bodyEntity.getBodyTagList(); ( i;ibodyTagList.size();i){ bodyTagList.get(i).validate(); } .tailerEntity.validate(); (request){ testReqID.setMust(); testReqID.validate(); } } decodeBody() { Set already HashSet(); [] bodyItems.body.split(BaseMsg.SOH); (bodyItems.lengthbodyItems[].equals()){ ; } ( i;ibodyItems.length;i){ []tagItemsbodyItems[i].split(); (tagItems.length){ InValidDataException(); } tagIdtagItems[]; (already.contains(tagId)){ InValidDataException(); } already.add(tagId); (.tagIdsSet.contains(tagId)){ ListTag tagList.bodyEntity.getBodyTagList(); ( j;jtagList.size();j){ Tag tagtagList.get(j); (tag.getTagId().equals(tagId)){ tag.setTagValue(tagItems[]); ; } } }{ InValidDataException(tagId); } } } isRequest() { request; } setRequest( request) { .request request; } Tag getTestReqID() { testReqID; } setTestReqID(Tag testReqID) { .testReqID testReqID; } Set getTagIdsSet() { tagIdsSet; } setTagIdsSet(Set tagIdsSet) { .tagIdsSet tagIdsSet; } }
处理逻辑:略