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
消息实现:
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;
}
}
消息处理:略