RE: [Quickfix-users] What is correct behavior if sender has error sending msg?
Brought to you by:
orenmnero
From: Brendan B. B. <br...@ka...> - 2003-07-13 02:46:13
|
> From: Brendan Boerner > > From: Oren Miller [mailto:ore...@ya...] > > Did you experience a particular problem with this? > Yes, but now that I'm trying to reproduce it, I can't <grrrr> :-(. > > What I was seeing were 'gaps' in the message store e.g. > > 8=FIX.4.1^A9=60^A35=2^A34=100^A49=CLYN7^A52=20030711-20:08:00^A56= > SLK^A7=87^ > A16=91^A10=165^A > 8=FIX.4.1^A9=60^A35=2^A34=101^A49=CLYN7^A52=20030711-20:08:00^A56= > SLK^A7=87^ > A16=92^A10=167^A > 8=FIX.4.1^A9=60^A35=2^A34=103^A49=CLYN7^A52=20030711-20:08:00^A56= > SLK^A7=87^ > A16=94^A10=171^A > 8=FIX.4.1^A9=60^A35=2^A34=104^A49=CLYN7^A52=20030711-20:08:00^A56= > SLK^A7=87^ > A16=95^A10=173^A > > which would cause the target to issue a resend request. Since it > couldn't be honored the target wouldn't allow further processing (I'm > pretty sure that the Sender didn't issue a Sequence Reset in this > case either). > > Next time I can reproduce I'll debug further. Ok, I can see it occur and have more insight into the problem. bool Session::sendRaw( Message& message, int num ) { ... if ( isLoggedOn() ) result = send( message.toString(messageString) ); if ( !num ) { MsgSeqNum msgSeqNum; header.getField( msgSeqNum ); m_state.set( msgSeqNum, messageString ); m_state.incrNextSenderMsgSeqNum(); } ... } The problem is occuring because isLoggedOn() is returning false (I see this most when I've had my client paused in the debugger for a bit - this is to be expected if the server wasn't getting any heartbeats from the client. I *think* I've also seen it when I slam > 50 orders at once right after getting a notification of Application::onLogon(). I haven't debugged into this much). Since messageString is constructed in the call to send(), m_state.set( msgSeqNum, messageString ) will attempt to write a "" string to the store, thus the gap. What's weird is that modifying it to be: message.toString(messageString); if ( isLoggedOn() ) result = send(messageString); still results in nothing being written to the store! I've traced into FileStore::set( int msgSeqNum, const std::string& msg ) and fwrite() is getting a valid message to write but it's not showing up in the file. I know this is occuring when I've created the problem when sending > 50 orders right after I've logged on, I don't know if the problem exists when I've logged off due to sitting in the debugger. Question: If not logged on, do we really want to queue messages? Suppose (to construct a contrived scenario) that the app sends an order to buy 1000 contracts of FOOBAR @ mkt where mkt is X. The connection is down for whatever reason for a significant length of time. The app is coded to issue a cancel if it doesn't get an order ack within some amount of time which is also queued. When the connection comes back up, the NewOrderSingle is sent out followed by the OrderRequestCancel. If the FIX server enforces logic that an OrderRequestCancel won't be honored until the NewOrderSingle is ACKed, the NewOrderSingle will have to enter the mkt in some fashion and the app will need to resend the OrderRequestCancel. If the mkt has moved significantly away from X in the interval that the link was down, the order could be filled at a price which could be detrimental to the person(s) funding the account... It seems to me that if the message is not queued if not logged on, the app can check the result from sendToTarget(), know the order wasn't sent and retry (or not) until it makes it through. Regards, Brendan |