Imported from previous forum
Hi All,
I am using QuickFix/J version (quickfixj-1.3.0) to implement the initiator on our side.
We are getting the messages from the acceptor which is maintained/provided by a clearing house.
We are using FIX version 4.2
The quickfix client implemented is launched in a separate JVM.If our application server crashes
or the network is down we will miss out on some of the messages sent during the day.
One of the ways to recover these messages is to get the send a resend request and get all the messages
for the day.I am trying to implement the Resend request.And here is where I am stuck/ not gettign all the messages for the day.
Here is the logic:
-
Applicaiton Server crashes.Restart the server and also restart the fix client.As soon as the
fix client logs in I am sending a RESEND request.Here is the code snippet.public void onLogon(SessionID sessionID) { {
//send a resend request to get all the trades for the current trading day.
//Get the current session
Session currentSession = Session.lookupSession(sessionID);
System.out.println("currentSession = “+currentSession);
try {
Message resendRequest = generateResendRequest(currentSession,“FIX.4.2”);
fixApiClient.log(“Resend Request for the day =”+resendRequest);
boolean success = Session.sendToTarget(resendRequest);
fixApiClient.log(”###########FINISHED sending Sent a resent Request for the day ##########. is success ? = "+success);
}
catch(SessionNotFound se) {
se.printStackTrace();
}
}private Message generateResendRequest(Session session,String beginString) throws SessionNotFound {
MessageFactory messageFactory = session.getMessageFactory();
Message resendRequest = messageFactory.create(beginString, MsgType.RESEND_REQUEST);int beginSeqNo = 1; int endSeqNo = 0; resendRequest.setInt(BeginSeqNo.FIELD, beginSeqNo); resendRequest.setInt(EndSeqNo.FIELD, endSeqNo); initializeHeader(resendRequest.getHeader(),session.getSessionID()); return resendRequest; //state.setResendRange(beginSeqNo, msgSeqNum - 1);}
private void initializeHeader(Message.Header header,SessionID sessionID) {
//state.setLastSentTime(SystemTime.currentTimeMillis()); header.setString(BeginString.FIELD, sessionID.getBeginString()); header.setString(SenderCompID.FIELD, sessionID.getSenderCompID()); header.setString(TargetCompID.FIELD, sessionID.getTargetCompID()); //header.setInt(MsgSeqNum.FIELD, getExpectedSenderNum()); //header.setUtcTimeStamp(SendingTime.FIELD, SystemTime.getDate(), includeMillis); header.setUtcTimeStamp(SendingTime.FIELD, SystemTime.getDate());}
When I run the fix client it sends a RESEND request to the acceptor.The log file shows the request as
8=FIX.4.29=5135=249=XXXX52=20071208-00:00:0156=YYYY7=216=010=255
I expected to get all the messages for the day, but it just sends me a messages starting from
currentMsgSeq -1 and carries on to the end.
I am definitely missing something.
Can you guys please help me to resolve this ?
- It would be great if sombody sends an example code snippet to get all
the messages for the current trading day.
Also let me know if I have to set any of the properties like
ResetOnLogout , ResetOnDisconnect to Y.If I set them to Y will I miss out any trades?
Appreciate your help.
Thanks
Bharath
Hi Barath,
I’m not using QuickFix, but I’m working with FIX 4.2 for one year now, implementing my own FIX engine that is in some kind similar to QuickFIX. Maybe I can give you some hints…
- Applicaiton Server crashes.Restart the server and also restart the
fix client.As soon as the fix client logs in I am sending a RESEND
request.Here is the code snippet.
When I run the fix client it sends a RESEND request to the acceptor.The
log file shows the request as 8=FIX.4.29=5135=249=XXXX52=20071208-
00:00:0156=YYYY7=216=010=255
The message looks quite good. It should provoke a resending beginning on sequence number 2. Did you try it out with different acceptors? Maybe the other side is not able to resend correctly…
There is a free FIX environment called OpenFIX (http://www.openfix.net/) were you can see also the Logfile of the acceptor. Maybe this helps on testing.
Also let me know if I have
to set any of the properties like ResetOnLogout , ResetOnDisconnect
to Y.If I set them to Y will I miss out any trades?
As far as I understand QuickFIX, the ResetOnDisconnect or ResetOnLogout would only reset the sequence numbers. But this is actually NOT what you want, because
1.) Probably your own sequence numbers will also be reset. This would lead to a ResendRequest from your counterparty…
2.) Probably they will set the ResetSeqNum Flag in the Logon Message which initiates a reset of sequence numbers on the other side. Some engines doesn’t allow this. Other ones allow it - but in this case, all messages sent earlier are “discarded”! So: If you reset the counterparties sequence numbers you won’t ever have a chance to receive the messages missed before!
The ResendRequest Message is your own chance to get message duplicates!
Hope that helps alittle bit … ![]()
Regards,
Eva
Hi Barath,
I’m not using QuickFix, but I’m working with FIX 4.2 for one year now,
implementing my own FIX engine that is in some kind similar to QuickFIX.
Maybe I can give you some hints…
- Applicaiton Server crashes.Restart the server and also restart the
fix client.As soon as the fix client logs in I am sending a RESEND
request.Here is the code snippet.When I run the fix client it sends a RESEND request to the
acceptor.The log file shows the request as 8=FIX.4.29=5135=249=XXXX52=20071208-
00:00:0156=YYYY7=216=010=255The message looks quite good. It should provoke a resending beginning on
sequence number 2. Did you try it out with different acceptors? Maybe
the other side is not able to resend correctly… There is a free FIX
environment called OpenFIX (http://www.openfix.net/) were you can see
also the Logfile of the acceptor. Maybe this helps on testing.Also let me know if I have to set any of the properties like
ResetOnLogout , ResetOnDisconnect to Y.If I set them to Y will I
miss out any trades?As far as I understand QuickFIX, the ResetOnDisconnect or ResetOnLogout
would only reset the sequence numbers. But this is actually NOT what you
want, because
1.) Probably your own sequence numbers will also be reset. This would
lead to a ResendRequest from your counterparty…
2.) Probably they will set the ResetSeqNum Flag in the Logon Message
which initiates a reset of sequence numbers on the other side. Some
engines doesn’t allow this. Other ones allow it - but in this case,
all messages sent earlier are “discarded”! So: If you reset the
counterparties sequence numbers you won’t ever have a chance to
receive the messages missed before!The ResendRequest Message is your own chance to get message duplicates!
Hope that helps alittle bit …
Regards, Eva
Thanks Eva.
Acually, I figured out a way to to get the resend working.we have to reset the seqeuence number for the session to the required number inorder to get the resend messages.
That is how Quickfix works.![]()