首页 > 其他分享 >fix协议介绍4-心跳

fix协议介绍4-心跳

时间:2022-10-10 14:32:51浏览次数:41  
标签:协议 tagIdsSet request fix tagId testReqID 心跳 new public


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.



fix协议介绍4-心跳_ide



心跳消息实现:

package cs.mina.codec.msg;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import cs.mina.exception.InValidDataException;

/*
*@author(huangxiaoping)
*@date 2013-10-24
*/
public class HeartbeatMsg extends BaseMsg {
private boolean request=true;
private Tag testReqID=new Tag("112","String",false);
private Set<String> tagIdsSet = new HashSet<String>();

public HeartbeatMsg(){
this.getHeadEntity().getMsgType().setTagValue("0");
tagIdsSet.add("112");
this.bodyEntity.getBodyTagList().add(testReqID);
}

@Override
public void validate() {
this.headEntity.validate();
List<Tag> bodyTagList=this.bodyEntity.getBodyTagList();
for(int i=0;i<bodyTagList.size();i++){
bodyTagList.get(i).validate();
}
this.tailerEntity.validate();
if(!request){
testReqID.setMust(true);
testReqID.validate();
}

}

@Override
public void decodeBody() {
Set<String> already=new HashSet<String>();
String[] bodyItems=this.body.split(BaseMsg.SOH);
if(bodyItems.length==1&&bodyItems[0].equals("")){
return;
}
for(int i=0;i<bodyItems.length;i++){
String[]tagItems=bodyItems[i].split("=");
if(tagItems.length!=2){
throw new InValidDataException("消息格式错误");
}
String tagId=tagItems[0];
if(already.contains(tagId)){
throw new InValidDataException("消息格式错误");
}
already.add(tagId);
if(this.tagIdsSet.contains(tagId)){
List<Tag> tagList=this.bodyEntity.getBodyTagList();
for(int j=0;j<tagList.size();j++){
Tag tag=tagList.get(j);
if(tag.getTagId().equals(tagId)){
tag.setTagValue(tagItems[1]);
break;
}
}
}else{
throw new InValidDataException("消息格式错误,"+tagId+"不在消息体内");
}
}

}

public boolean isRequest() {
return request;
}

public void setRequest(boolean request) {
this.request = request;
}

public Tag getTestReqID() {
return testReqID;
}

public void setTestReqID(Tag testReqID) {
this.testReqID = testReqID;
}

public Set<String> getTagIdsSet() {
return tagIdsSet;
}

public void setTagIdsSet(Set<String> tagIdsSet) {
this.tagIdsSet = tagIdsSet;
}

}


处理逻辑:略




标签:协议,tagIdsSet,request,fix,tagId,testReqID,心跳,new,public
From: https://blog.51cto.com/u_11979904/5743363

相关文章

  • fix协议介绍6-重发消息
    FIX.5.0SP2MessageResendRequest [type'2']Theresendrequestissentbythereceivingapplicationtoinitiatetheretransmissionofmessages.Thisfunction......
  • fix协议介绍7-序列号重置
    FIX.5.0SP2MessageSequenceReset [type'4']Thesequenceresetmessageisusedbythesendingapplicationtoresettheincomingsequencenumberontheopposi......
  • fix协议介绍8-Reject消息
    FIX.5.0SP2MessageReject [type'3']Therejectmessageshouldbeissuedwhenamessageisreceivedbutcannotbeproperlyprocessedduetoasession-levelr......
  • RFID Gen2协议Session含义
    RFIDGen2协议中Session参数主要为了方便标签盘点。每个标签都包含s0-s3总计4种session,每种session中又各有A,B两种inventoriedflag,这些flag在不同Session之间不互通。换......
  • DFP 数据转发协议应用实例 3.LoRA 中继-使用频道实现
    DFP数据转发协议应用实例 3.LoRA中继-使用频道实现DFP是什么?稳控科技编写的一套数据转发规则,取自“自由转发协议FFP(FreeForwardProtocol)”,或者DFP(DoubleFProt......
  • 如何实现汇川PLC和工业机器人的协议解析与数据采集?
    汇川是一家专注于工业自动化的设备制造商,具备一整套完善的产品与服务,涉及变频器、伺服系统、PLC、HMI触摸屏、电动汽车电机控制器、光伏逆变器等等,在制造业、新能源、环保节......
  • 实验3:OpenFlow协议分析实践
    拓扑文件:  ping截图:   抓包:1.hello  6633接口发送到交换机40276接口,openflow版本1.0  交换机40276接口发送到控制器6633接口,openflow版本1.5双......
  • 实验3:OpenFlow协议分析实践
    实验3:OpenFlow协议分析实践一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与......
  • 实验3:OpenFlow协议分析实践
    实验3:OpenFlow协议分析实践一、实验目的能够运用wireshark对OpenFlow协议数据交互过程进行抓包;能够借助包解析工具,分析与解释OpenFlow协议的数据包交互过程与机制......
  • 实验3:OpenFlow协议分析实践
    1.搭建下图所示拓扑,完成相关IP配置,并实现主机与主机之间的IP通信。用抓包软件获取控制器与交换机之间的通信数据。2.查看抓包结果,分析OpenFlow协议中交换机与控制器......