Re: [Quickfix-developers] Efficient Message creation
Brought to you by:
orenmnero
From: <or...@qu...> - 2008-04-24 18:24:00
|
<html><body><div>There is a method in the C++ message called identifyType which looks at a string and parses it just enough to identify the type. We could expose this though that would still require converting the C++ string to a java string twice which isn't the most efficient thing in the world either. Probably the best thing to do would be to reimplement that method in java.</div> <div> </div> <div>The existing C++ method looks like this:</div> <div> </div> <div>inline MsgType identifyType( const std::string& message )<BR>throw( MessageParseError )<BR>{<BR> std::string::size_type pos = message.find( "\00135=" );<BR> if ( pos == std::string::npos ) throw MessageParseError();</div> <div> std::string::size_type startValue = pos + 4;<BR> std::string::size_type soh = message.find_first_of( '\001', startValue );<BR> if ( soh == std::string::npos ) throw MessageParseError();</div> <div> std::string value = message.substr( startValue, soh - startValue );<BR> return MsgType( value );<BR>}<BR></div> <div>Basically just searches for the first instance of [SOH]35= and the following [SOH], everything in between is the msgtype. Pretty efficient since the MsgType is always guaranteed to be in the same place near the start of the message.</div> <div> </div> <div>--oren</div> <BLOCKQUOTE style="PADDING-LEFT: 8px; MARGIN-LEFT: 8px; BORDER-LEFT: blue 2px solid" webmail="1">-------- Original Message --------<BR>Subject: [Quickfix-developers] Efficient Message creation<BR>From: Mike Perik <mic...@ya...><BR>Date: Thu, April 24, 2008 12:05 pm<BR>To: <a href="mailto:qui...@li...">qui...@li...</a><BR><BR>QuickFIX Documentation: <A href="http://www.quickfixengine.org/quickfix/doc/html/index.html" target=_blank><a href="http://www.quickfixengine.org/quickfix/doc/html/index.html">http://www.quickfixengine.org/quickfix/doc/html/index.html</a></A><BR>QuickFIX Support: <A href="http://www.quickfixengine.org/services.html" target=_blank><a href="http://www.quickfixengine.org/services.html">http://www.quickfixengine.org/services.html</a></A><BR><BR>If I have a raw FIX string what is the most efficient method for creating a Message object out of it using the Java API?<BR><BR>The way I was doing it was this:<BR><BR>// Have to do this to get the 'BeginString' and 'MsgType' fields<BR>// I guess I could do some manual field checking/lookup<BR>Message fixmsg = new Message(fixmsgstr);<BR>String beginString = fixmsg.getHeader().getString(BeginString.FIELD);<BR>String fixMsgType = fixmsg.getHeader().getString(MsgType.FIELD);<BR><BR>// m_messageFactory is an instance of the DefaultMessageFactory<BR>// This returns the FIX version specific message<BR>m_messageFactory.create(beginString, fixMsgType);<BR>fixmsg.initFromString(fixmsgstr, true);<BR><BR><BR>The problem with the way I doing it is that the raw FIX message string gets parsed twice. I need the FIX version specific Message object so when I call the crack() method the MessageCracker() can determine the version specific method to call. I'm getting a ClassCastException right now.<BR><BR>Is there another way to do this? 'This' being create a version specific Message object from a raw message string.<BR><BR>Thanks,<BR>Mike<BR><BR><BR><BR>____________________________________________________________________________________<BR>Be a better friend, newshound, and <BR>know-it-all with Yahoo! Mobile. Try it now. <A href="http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ" target=_blank><a href="http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ">http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ</a></A><BR><BR>-------------------------------------------------------------------------<BR>This <a href="http://SF.net">SF.net</a> email is sponsored by the 2008 JavaOne(SM) Conference <BR>Don't miss this year's exciting event. There's still time to save $100. <BR>Use priority code J8TL2D2. <BR><A href="http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone" target=_blank><a href="http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone">http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone</a></A><BR>_______________________________________________<BR>Quickfix-developers mailing list<BR><A onclick="Popup.composeWindow('pcompose.php?sendto=Quickfix-developers%40lists.sourceforge.net'); return false;" href="#Compose">Quickfix-developers<B></B>@lists.sourceforge.net</A><BR><A href="https://lists.sourceforge.net/lists/listinfo/quickfix-developers" target=_blank><a href="https://lists.sourceforge.net/lists/listinfo/quickfix-developers">https://lists.sourceforge.net/lists/listinfo/quickfix-developers</a></A><BR></BLOCKQUOTE></body></html> |