[QFJ-286] Sequence number not correct after ResendRequest when PersistMessages=N (ATServer configuration) Created: 10/Jan/08  Updated: 15/Nov/12  Resolved: 18/Feb/09

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.3.0
Fix Version/s: 1.5.0

Type: Bug Priority: Default
Reporter: Peter Eriksson Assignee: Steve Bate
Resolution: Fixed Votes: 1
Labels: None
Environment:

WinXP x64



 Description   

Case 8_OnlyAminMessages.def faild.

Suggestion for solution in Session.java:

private void nextResendRequest(Message resendRequest) throws IOException, RejectLogon,
FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType,
InvalidMessage {
if (!verify(resendRequest, false, false))

{ return; }

int beginSeqNo = resendRequest.getInt(BeginSeqNo.FIELD);
int endSeqNo = resendRequest.getInt(EndSeqNo.FIELD);

getLog().onEvent("Received ResendRequest FROM: " + beginSeqNo + " TO: " + endSeqNo);

String beginString = sessionID.getBeginString();
int expectedSenderNum = getExpectedSenderNum();
if (beginString.compareTo(FixVersions.BEGINSTRING_FIX42) >= 0 && endSeqNo == 0

beginString.compareTo(FixVersions.BEGINSTRING_FIX42) <= 0 && endSeqNo == 999999
endSeqNo >= expectedSenderNum) { endSeqNo = expectedSenderNum - 1; }

if (!persistMessages) {
endSeqNo += 1;
int next = state.getNextSenderMsgSeqNum();
if (endSeqNo > next)

{ endSeqNo = next; }

generateSequenceReset(beginSeqNo, endSeqNo);

}
else {
ArrayList<String> messages = new ArrayList<String>();
state.get(beginSeqNo, endSeqNo, messages);

int msgSeqNum = 0;
int begin = 0;
int current = beginSeqNo;

for (String message : messages) {
Message msg = parseMessage((String) message);
msgSeqNum = msg.getHeader().getInt(MsgSeqNum.FIELD);
String msgType = msg.getHeader().getString(MsgType.FIELD);

if ((current != msgSeqNum) && begin == 0)

{ begin = current; }

if (msgType.length() == 1 && "0A12345".indexOf(msgType) != -1) {
if (begin == 0)

{ begin = msgSeqNum; }

} else {
if (resend(msg)) {
if (begin != 0)

{ generateSequenceReset(begin, msgSeqNum); }

send(msg.toString());
getLog().onEvent("Resending Message: " + msgSeqNum);
begin = 0;
} else

{ if (begin == 0) begin = msgSeqNum; }

}
current = msgSeqNum + 1;
}

if (begin != 0)

{ generateSequenceReset(begin, msgSeqNum + 1); }

if (endSeqNo > msgSeqNum)

{ endSeqNo = endSeqNo + 1; int next = state.getNextSenderMsgSeqNum(); if (endSeqNo > next) endSeqNo = next; generateSequenceReset(beginSeqNo, endSeqNo); }

}

int tMsgSeqNum = resendRequest.getHeader().getInt(MsgSeqNum.FIELD);
if (!isTargetTooHigh(tMsgSeqNum) && !isTargetTooLow(tMsgSeqNum))

{ state.incrNextTargetMsgSeqNum(); }

}



 Comments   
Comment by Staffan Ulfberg [ 06/Feb/08 ]

I found this when googling for this issue since I discovered it in the C++ version a few hours ago. The fix above is the equivalent to what I would suggest for the C++ code. I checked the bug tracker for the quickfix (not j) project but could not find anything about this.

Comment by Jason Aubrey [ 15/Jan/09 ]

Just to summarize a bit (since the indenting is a bit lost), the key parts of this code are:
1) The removal of the 'return' after the first occurrence of 'generateSequenceReset'
2) The addition of the 'else' block immediately after the removed 'return'
3) Since there's no return (due to 1) the code skips over the else (due to 2) when !persistMessages and does the incrNextTargetMsgSeqNum

Any other changes I see here seem superfluous in my local revision (899).

Generated at Sat Nov 23 10:47:53 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.