[Quickfix-users] Cracking non-typesafe message in .Net fails
Brought to you by:
orenmnero
From: abaraff <ab...@ra...> - 2011-05-20 13:47:06
|
I'm trying to find a method to persist messages for restoring state in my application. I've been unable to get the new Message(string) constructor to return a new message where the fields are identical to the original. I've detailed the bug in an earlier post. Another logical way of persisting a message would be to store all the header field key/value pairs and all the body key value pairs. I've restored the message by adding the necessary fields back to a new message. While the string output by this message is identical to the original, there is obviously some problem because the cracker throws an exception with the cloned version but not the original. I realize this is a non-typesafe approach to creating a message, if anyone has an alternate suggestion that will adapt to restoring any message type, I'm interested in the suggestion. public void fromApp(Message msg, SessionID sessionID) { System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.FFFF") + " FromApp:" + sessionID.ToString() + "\t" + msg.ToString()); try { string message = msg.ToString(); Message newMessage = new Message(); foreach(Field fld in msg.getHeader()) { newMessage.getHeader().setField(fld.getField(), fld.getObject().ToString()); } foreach (Field fld in msg) { newMessage.setField(fld.getField(), fld.getObject().ToString()); } crack(msg, sessionID); try { crack(newMessage, sessionID); } catch (Exception e2) { System.Diagnostics.Debug.WriteLine(e2.ToString()); System.Diagnostics.Debug.WriteLine(msg.ToString() == newMessage.ToString()); System.Diagnostics.Debug.WriteLine("orig: " + msg.ToString()); System.Diagnostics.Debug.WriteLine("new: " + newMessage.ToString()); System.Diagnostics.Debug.WriteLine("round trip failed"); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } } public override void onMessage(QuickFix42.NewOrderSingle message, SessionID session) { System.Diagnostics.Debug.WriteLine("New Order Single"); } output: 14:30:47.4179 FromApp:FIX.4.2:SCTC->SCT1 8=FIX.4.29=18035=D34=249=SCT152=20110519-18:30:47.41756=SCTC11=SCT20110519-143047_0000218=121=138=20040=154=155=IBM58=SCT20110519-143047_0000259=060=20110519-14:30:47100=DB-SMART10=013 New Order Single A first chance exception of type 'QuickFix.UnsupportedMessageType' occurred in quickfix_net_messages.dll QuickFix.UnsupportedMessageType: Exception of type 'QuickFix.UnsupportedMessageType' was thrown. at QuickFix42.MessageCracker.onMessage(Message message, SessionID session) at QuickFix42.MessageCracker.crack(Message message, SessionID sessionID) at FIXServer.FIXServerApp.fromApp(Message msg, SessionID sessionID) in C:\Dev\Abaraff\FIXServer\FIXServer\FIXServerApp.cs:line 238 True orig: 8=FIX.4.29=18035=D34=249=SCT152=20110519-18:30:47.41756=SCTC11=SCT20110519-143047_0000218=121=138=20040=154=155=IBM58=SCT20110519-143047_0000259=060=20110519-14:30:47100=DB-SMART10=013 new: 8=FIX.4.29=18035=D34=249=SCT152=20110519-18:30:47.41756=SCTC11=SCT20110519-143047_0000218=121=138=20040=154=155=IBM58=SCT20110519-143047_0000259=060=20110519-14:30:47100=DB-SMART10=013 round trip failed -- View this message in context: http://old.nabble.com/Cracking-non-typesafe-message-in-.Net-fails-tp31664242p31664242.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |