本文整理汇总了Java中quickfix.field.MsgSeqNum类的典型用法代码示例。如果您正苦于以下问题:Java MsgSeqNum类的具体用法?Java MsgSeqNum怎么用?Java MsgSeqNum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MsgSeqNum类属于quickfix.field包,在下文中一共展示了MsgSeqNum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: affixSeqNum
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void affixSeqNum(final List<Message> listMsg, final int firstSeqNum, boolean ignoreSeqNumFromMsg) {
int currentNum = firstSeqNum;
for (Message msg : listMsg) {
int msgSeqNum = extractSeqNum(msg);
if (msgSeqNum == 0) {
msg.getHeader().setInt(MsgSeqNum.FIELD, currentNum++);
} else {
if (currentNum==msgSeqNum && msgSeqNum!=0) {
// expected SeqNum already used
currentNum = msgSeqNum + 1;
} else {
if (ignoreSeqNumFromMsg) {
log.warn("SeqNum is not null in message, but enabled mode 'ignoreSeqNumInMsg' " +
"For this message will be assigned the current seqNum. Message:" + msg);
msg.getHeader().setInt(MsgSeqNum.FIELD, currentNum++);
} else {
log.warn("In message present unexpected SeqNum. SeqNum from it message will be apply as the current SeqNum. " +
"Normal behavior is not guaranteed. Message: " + msg);
currentNum = msgSeqNum + 1;
}
}
}
}
}
示例2: generateSequenceReset
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
/**
*
* @param receivedMessage if not null, it is the message received and upon which the resend request is generated
* @param beginSeqNo
* @param endSeqNo
* @throws FieldNotFound
*/
private void generateSequenceReset(Message receivedMessage, int beginSeqNo, int endSeqNo)
throws FieldNotFound {
final Message sequenceReset = messageFactory.create(sessionID.getBeginString(),
MsgType.SEQUENCE_RESET);
final int newSeqNo = endSeqNo;
final Header header = sequenceReset.getHeader();
header.setBoolean(PossDupFlag.FIELD, true);
initializeHeader(header);
header.setUtcTimeStamp(OrigSendingTime.FIELD, header.getUtcTimeStamp(SendingTime.FIELD));
header.setInt(MsgSeqNum.FIELD, beginSeqNo);
sequenceReset.setInt(NewSeqNo.FIELD, newSeqNo);
sequenceReset.setBoolean(GapFillFlag.FIELD, true);
if (receivedMessage != null && enableLastMsgSeqNumProcessed) {
try {
sequenceReset.getHeader().setInt(LastMsgSeqNumProcessed.FIELD,
receivedMessage.getHeader().getInt(MsgSeqNum.FIELD));
} catch (final FieldNotFound e) {
//should not happen as MsgSeqNum must be present
getLog().onErrorEvent("Received message without MsgSeqNum " + receivedMessage);
}
}
sendViaFixFilter(sequenceReset, beginSeqNo);
getLog().onEvent("Sent SequenceReset TO: " + newSeqNo);
}
示例3: generateLogout
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
/**
* To generate a logout message
* @param otherLogout if not null, the logout message that is causing a logout to be sent
* @param text
*/
private void generateLogout(Message otherLogout, String text) {
final Message logout = messageFactory.create(sessionID.getBeginString(), MsgType.LOGOUT);
initializeHeader(logout.getHeader());
if (text != null && !"".equals(text)) {
logout.setString(Text.FIELD, text);
}
if (otherLogout != null && enableLastMsgSeqNumProcessed) {
try {
logout.getHeader().setInt(LastMsgSeqNumProcessed.FIELD,
otherLogout.getHeader().getInt(MsgSeqNum.FIELD));
} catch (final FieldNotFound e) {
//should not happen as MsgSeqNum must be present
getLog().onErrorEvent("Received logout without MsgSeqNum");
}
}
sendViaFixFilter(logout, 0);
state.setLogoutSent(true);
}
示例4: generateReject
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void generateReject(Message message, String str) throws FieldNotFound, IOException {
final String beginString = sessionID.getBeginString();
final Message reject = messageFactory.create(beginString, MsgType.REJECT);
final Header header = message.getHeader();
reject.reverseRoute(header);
initializeHeader(reject.getHeader());
final String msgType = header.getString(MsgType.FIELD);
final String msgSeqNum = header.getString(MsgSeqNum.FIELD);
if (beginString.compareTo(FixVersions.BEGINSTRING_FIX42) >= 0) {
reject.setString(RefMsgType.FIELD, msgType);
}
reject.setString(RefSeqNum.FIELD, msgSeqNum);
if (!msgType.equals(MsgType.LOGON) && !msgType.equals(MsgType.SEQUENCE_RESET)
&& !isPossibleDuplicate(message)) {
state.incrNextTargetMsgSeqNum();
}
reject.setString(Text.FIELD, str);
sendViaFixFilter(reject, 0);
getLog().onErrorEvent("Reject sent for Message " + msgSeqNum + ": " + str);
}
示例5: generateBusinessReject
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void generateBusinessReject(Message message, int err, int field) throws FieldNotFound,
IOException {
final Message reject = messageFactory.create(sessionID.getBeginString(),
MsgType.BUSINESS_MESSAGE_REJECT);
initializeHeader(reject.getHeader());
final String msgType = message.getHeader().getString(MsgType.FIELD);
final String msgSeqNum = message.getHeader().getString(MsgSeqNum.FIELD);
reject.setString(RefMsgType.FIELD, msgType);
reject.setString(RefSeqNum.FIELD, msgSeqNum);
reject.setInt(BusinessRejectReason.FIELD, err);
state.incrNextTargetMsgSeqNum();
final String reason = BusinessRejectReasonText.getMessage(err);
setRejectReason(reject, field, reason, field != 0);
getLog().onErrorEvent(
"Reject sent for Message " + msgSeqNum + (reason != null ? (": " + reason) : "")
+ (field != 0 ? (": tag=" + field) : ""));
sendViaFixFilter(reject, 0);
}
示例6: generateLogon
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void generateLogon(Message otherLogon) throws FieldNotFound {
final Message logon = messageFactory.create(sessionID.getBeginString(), MsgType.LOGON);
logon.setInt(EncryptMethod.FIELD, EncryptMethod.NONE_OTHER);
if (state.isResetReceived()) {
logon.setBoolean(ResetSeqNumFlag.FIELD, true);
}
logon.setInt(HeartBtInt.FIELD, otherLogon.getInt(HeartBtInt.FIELD));
if (sessionID.isFIXT()) {
logon.setField(senderDefaultApplVerID);
}
if (enableLastMsgSeqNumProcessed) {
logon.getHeader().setInt(LastMsgSeqNumProcessed.FIELD,
otherLogon.getHeader().getInt(MsgSeqNum.FIELD));
}
initializeHeader(logon.getHeader());
//field 789
if (enableNextExpectedMsgSeqNum) {
//the expected target num will be incremented one the other logon has been processed
logon.setInt(NextExpectedMsgSeqNum.FIELD, getExpectedTargetNum() + 1);
}
sendViaFixFilter(logon, 0);
state.setLogonSent(true);
}
示例7: extractSeqNum
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
protected int extractSeqNum(final Message inMsg) {
int result = 0;
try {
result = inMsg.getHeader().getField(new IntField(MsgSeqNum.FIELD)).getValue();
} catch (final FieldNotFound inFieldNotFound) {
// do nothing
}
return result;
}
示例8: initializeHeader
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void initializeHeader(Message.Header header) {
state.setLastSentTime(SystemTime.currentTimeMillis());
header.setString(BeginString.FIELD, sessionID.getBeginString());
header.setString(SenderCompID.FIELD, sessionID.getSenderCompID());
optionallySetID(header, SenderSubID.FIELD, sessionID.getSenderSubID());
optionallySetID(header, SenderLocationID.FIELD, sessionID.getSenderLocationID());
header.setString(TargetCompID.FIELD, sessionID.getTargetCompID());
optionallySetID(header, TargetSubID.FIELD, sessionID.getTargetSubID());
optionallySetID(header, TargetLocationID.FIELD, sessionID.getTargetLocationID());
header.setInt(MsgSeqNum.FIELD, getExpectedSenderNum());
insertSendingTime(header);
}
示例9: generateHeartbeat
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void generateHeartbeat(Message testRequest) throws FieldNotFound {
final Message heartbeat = messageFactory.create(sessionID.getBeginString(),
MsgType.HEARTBEAT);
initializeHeader(heartbeat.getHeader());
if (testRequest.isSetField(TestReqID.FIELD)) {
heartbeat.setString(TestReqID.FIELD, testRequest.getString(TestReqID.FIELD));
}
if (enableLastMsgSeqNumProcessed) {
heartbeat.getHeader().setInt(LastMsgSeqNumProcessed.FIELD,
testRequest.getHeader().getInt(MsgSeqNum.FIELD));
}
sendViaFixFilter(heartbeat, 0);
}
示例10: doTargetTooLow
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private boolean doTargetTooLow(Message msg) throws FieldNotFound, IOException {
if (!isPossibleDuplicate(msg)) {
final int msgSeqNum = msg.getHeader().getInt(MsgSeqNum.FIELD);
final String text = "MsgSeqNum too low, expecting " + getExpectedTargetNum()
+ " but received " + msgSeqNum;
generateLogout(text);
throw new SessionException(text);
}
return validatePossDup(msg);
}
示例11: doTargetTooHigh
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void doTargetTooHigh(Message msg) throws FieldNotFound, IOException, InvalidMessage {
final Message.Header header = msg.getHeader();
final String beginString = header.getString(BeginString.FIELD);
final int msgSeqNum = header.getInt(MsgSeqNum.FIELD);
getLog().onErrorEvent(
"MsgSeqNum too high, expecting " + getExpectedTargetNum() + " but received "
+ msgSeqNum + ": " + msg);
// automatically reset or disconnect the session if we have a problem when the connector is running
if (resetOrDisconnectIfRequired(msg)) {
return;
}
state.enqueue(msgSeqNum, msg);
getLog().onEvent("Enqueued at pos " + msgSeqNum + ": " + msg);
if (state.isResendRequested()) {
final int[] range = state.getResendRange();
if (!redundantResentRequestsAllowed && msgSeqNum >= range[0]) {
getLog().onEvent(
"Already sent ResendRequest FROM: " + range[0] + " TO: " + range[1]
+ ". Not sending another.");
return;
}
}
generateResendRequest(beginString, msgSeqNum);
}
示例12: sendViaFixFilter
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private boolean sendViaFixFilter(final Message message, final int num) {
// sequence number must be locked until application
// callback returns since it may be effectively rolled
// back if the callback fails.
state.lockSenderMsgSeqNum();
try {
if (isFixFilterOutEnabled()) {
List<Message> messageFilteredList;
try {
if (num != 0) {
message.getHeader().setInt(MsgSeqNum.FIELD, num);
messageFilteredList = fixFilterOut.filter(sessionID, message, num);
} else {
int seqNum = getExpectedSenderNum();
message.getHeader().setInt(MsgSeqNum.FIELD, seqNum);
messageFilteredList = fixFilterOut.filter(sessionID, message, seqNum);
}
for (final Message msg : messageFilteredList) { // filter should take care about seqNum
sendMsgWithoutSeqNumLock(msg, extractSeqNum(msg), true);
}
} catch (final SkipMessageSignal inSignal) {
// TODO: it real need exception for skip? if we skip message - we must return true or false?
if (log.isTraceEnabled()) {
log.trace(sessionID + "msg skip: " + message);
}
}
// TODO: fixme! always return true...
return true;
} else {
return sendMsgWithoutSeqNumLock(message, num, false);
}
} finally {
state.unlockSenderMsgSeqNum();
}
}
示例13: sendAsRaw
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
/**
*
* @param message - message which send
* @param initializeHeader - flag responsible for initialize all required header field.
* If 'false' than will be initialize only SendingTime and SeqNum
* @return
*/
public boolean sendAsRaw(final Message message, final boolean initializeHeader) {
state.lockSenderMsgSeqNum();
try {
Header header = message.getHeader();
if (initializeHeader) {
// initialize all required header field
initializeHeader(header);
} else {
// initialize only SendingTime and MsgSeq
insertSendingTime(header);
header.setInt(MsgSeqNum.FIELD, getExpectedSenderNum());
}
boolean sendResult = sendViaRawFilter(message.toString());
if (sendResult) {
try {
state.incrNextSenderMsgSeqNum();
} catch (IOException ioe) {
logThrowable(state.getLog(), "Error accessing message fields", ioe);
return false;
}
}
return sendResult;
} finally {
state.unlockSenderMsgSeqNum();
}
}
示例14: extractSeqNum
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
public static int extractSeqNum(final Message inMsg) {
int result = 0;
try {
result = inMsg.getHeader().getField(new IntField(MsgSeqNum.FIELD)).getValue();
} catch (final FieldNotFound inFieldNotFound) {
if (log.isDebugEnabled()) {
log.debug("no SeqNum for msg: " + inMsg);
}
}
return result;
}
示例15: parse
import quickfix.field.MsgSeqNum; //导入依赖的package包/类
private void parse(DataDictionary dataDictionary) {
FIXProtocol fixProtocol = FIXProtocol.getInstance();
String msgStr = message.toString();
msgType = FIXProtocol.getMsgType(msgStr);
Field<Object> field = fixProtocol.getField(msgStr, MsgType.FIELD, dataDictionary);
msgTypeDesc = (String) field.getObject();
try {
msgTypeDesc = FIXProtocol.getMsgTypeDescription(msgStr);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
field = fixProtocol.getField(msgStr, SenderCompID.FIELD, dataDictionary);
senderCompId = (String) field.getObject();
field = fixProtocol.getField(msgStr, SenderSubID.FIELD, dataDictionary);
if (field != null)
senderSubId = (String) field.getObject();
field = fixProtocol.getField(msgStr, TargetCompID.FIELD, dataDictionary);
targetCompId = (String) field.getObject();
field = fixProtocol.getField(msgStr, TargetSubID.FIELD, dataDictionary);
if (field != null)
targetSubId = (String) field.getObject();
field = fixProtocol.getField(msgStr, BeginString.FIELD, dataDictionary);
beginString = (String) field.getObject();
field = fixProtocol.getField(msgStr, MsgSeqNum.FIELD, dataDictionary);
msgSeqNum = Integer.valueOf((String) field.getObject());
}