您的位置:首页 > 其它

fix协议介绍8-Reject消息

2013-12-13 12:32 816 查看


FIX.5.0SP2 Message

Reject [type '3']

The reject message should be issued when a message is received but cannot be properly processed due to a session-level rule violation. An example of when a reject may be appropriate would be the receipt of a message with invalid basic data which successfully
passes de-encryption, CheckSum and BodyLength checks.

Added FIX.2.7

Expand Components | Collapse Components
Field or ComponentField NameFIXML nameReq'dCommentsDepr.

ComponentStandardHeaderBaseHeader
MsgType = 3

45RefSeqNum@RefSeqNum
MsgSeqNum of rejected message

371RefTagID@RefTagIDThe tag number of the FIX field being referenced.

372RefMsgType@RefMsgTypThe MsgType of the FIX message being referenced.

1130RefApplVerID@RefApplVerIDRecommended when rejecting an application message that does not explicitly provide ApplVerID ( 1128) on the message being rejected. In this case the value from the DefaultApplVerID(1137) or the default value
specified in the NoMsgTypes repeating group on the logon message should be provided.

1406RefApplExtID@RefApplExtIDRecommended when rejecting an application message that does not explicitly provide ApplExtID(1156) on the rejected message. In this case the value from the DefaultApplExtID(1407) or the default value specified
in the NoMsgTypes repeating group on the logon message should be provided.

1131RefCstmApplVerID@RefCstmApplVerIDRecommended when rejecting an application message that does not explicitly provide CstmApplVerID(1129) on the message being rejected. In this case the value from the DefaultCstmApplVerID(1408) or the default
value specified in the NoMsgTypes repeating group on the logon message should be provided.

373SessionRejectReasonCode to identify reason for a session-level Reject message.

58Text@TxtWhere possible, message to explain reason for rejection

354EncodedTextLen@EncTxtLenMust be set if EncodedText field is specified and must immediately precede it.

355EncodedText@EncTxtEncoded (non-ASCII characters) representation of the Text field in the encoded format specified via the MessageEncoding field.

ComponentStandardTrailer
消息实现:
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-11-25
*/
public class RejectMsg extends BaseMsg {
private Tag refSeqNum=new Tag("45","SeqNum",true);
private Tag refTagID=new Tag("371","int",false);
private Tag refMsgType=new Tag("372","String",false);
private Tag sessionRejectReason=new Tag("373","int",false);
private Tag text=new Tag("58","String",false);
private Tag encodedTextLen=new Tag("354","Length",false);
private Tag encodedText=new Tag("355","data",false);
private Set<String> tagIdsSet=new HashSet<String>();
public RejectMsg(){
this.getHeadEntity().getMsgType().setTagValue("3");
tagIdsSet.add("45");
tagIdsSet.add("371");
tagIdsSet.add("372");
tagIdsSet.add("373");
tagIdsSet.add("58");
tagIdsSet.add("354");
tagIdsSet.add("355");
this.getBodyEntity().getBodyTagList().add(refSeqNum);
this.getBodyEntity().getBodyTagList().add(refTagID);
this.getBodyEntity().getBodyTagList().add(refMsgType);
this.getBodyEntity().getBodyTagList().add(sessionRejectReason);
this.getBodyEntity().getBodyTagList().add(text);
this.getBodyEntity().getBodyTagList().add(encodedTextLen);
this.getBodyEntity().getBodyTagList().add(encodedText);
}
@Override
public void decodeBody() {
Set<String> already=new HashSet<String>();
String[] bodyItems=this.body.split(BaseMsg.SOH);
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("消息格式错误");
}
}

}

@Override
public void validate() {
if(refMsgType.getTagValue()!=null){
if(MsgUtil.msgTypeMap.get(refMsgType.getTagValue())==null){
throw new InValidDataException("refMsgType错误");
}
}
if(sessionRejectReason.getTagValue()!=null){
if(!MsgUtil.sessionRejectReason.contains(sessionRejectReason.getTagValue())){
throw new InValidDataException("sessionRejectReason错误");
}
}
if(encodedText.getTagValue()!=null){
encodedTextLen.setMust(true);
}
this.headEntity.validate();
List<Tag> bodyTagList=this.bodyEntity.getBodyTagList();
for(int i=0;i<bodyTagList.size();i++){
bodyTagList.get(i).validate();
}
this.tailerEntity.validate();

}

public Tag getRefSeqNum() {
return refSeqNum;
}

public void setRefSeqNum(Tag refSeqNum) {
this.refSeqNum = refSeqNum;
}

public Tag getRefTagID() {
return refTagID;
}

public void setRefTagID(Tag refTagID) {
this.refTagID = refTagID;
}

public Tag getRefMsgType() {
return refMsgType;
}

public void setRefMsgType(Tag refMsgType) {
this.refMsgType = refMsgType;
}

public Tag getSessionRejectReason() {
return sessionRejectReason;
}

public void setSessionRejectReason(Tag sessionRejectReason) {
this.sessionRejectReason = sessionRejectReason;
}

public Tag getText() {
return text;
}

public void setText(Tag text) {
this.text = text;
}

public Tag getEncodedTextLen() {
return encodedTextLen;
}

public void setEncodedTextLen(Tag encodedTextLen) {
this.encodedTextLen = encodedTextLen;
}

public Tag getEncodedText() {
return encodedText;
}

public void setEncodedText(Tag encodedText) {
this.encodedText = encodedText;
}

}


消息处理:略
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: