From: <th...@co...> - 2011-01-13 00:27:18
|
Baljeet, I am not quite sure what you have going on there, but following is the basic idea with QuickFix/J... General setup of FIX application : Your class should... extend quickfix.MessageCracker and implement quickfix.Application This code to implement Application... @Override public void fromApp(Message message, SessionID sessionID) throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { final String msgTypeName = message.getClass().getSimpleName(); try { // IMPORTANT NOTE... the crack() method eventually calls your onMessage() method(s) crack( message, sessionID ); } catch (RuntimeException ex) { logger.log( Level.SEVERE, "Unable to crack '" + msgTypeName + "' message from session (" + sessionID + ")", ex ); } } This code to setup and start your sessions... FixProcessor application = new FixProcessor(); SessionSettings sessionSettings = new SessionSettings( new FileInputStream( sessionSettingsFileName ) ); MessageStoreFactory storeFactory = new FileStoreFactory( sessionSettings ); LogFactory logFactory = new FileLogFactory( sessionSettings ); MessageFactory messageFactory = new DefaultMessageFactory(); // SETUP FOR AN INITIATOR (use ThreadedSocketInitiator if supporting multiple sessions)... SocketInitiator initiator = null; try { initiator = new SocketInitiator( application, storeFactory, sessionSettings, logFactory, messageFactory ); } catch (ConfigError ex) { logger.log( Level.WARNING, "Unable to create SocketInitiator" ); throw ex; } try { initiator.start(); logger.log( Level.INFO, "SocketInitiator started" ); } catch (ConfigError ex) { logger.log( Level.WARNING, "Unable to start SocketInitiator" ); throw ex; } // SETUP FOR AN ACCEPTOR (use ThreadedSocketAcceptor if supporting multiple sessions)... SocketAcceptor acceptor = null; try { acceptor = new SocketAcceptor( application, storeFactory, sessionSettings, logFactory, messageFactory ); } catch (ConfigError ex) { logger.log( Level.WARNING, "Unable to create SocketAcceptor", ex ); throw ex; } try { acceptor.start(); logger.log( Level.INFO, "SocketAcceptor started" ); } catch (ConfigError ex) { logger.log( Level.WARNING, "Unable to start SocketAcceptor", ex ); throw ex; } Code to get a Session... SessionID sessionID = new SessionID( FixVersions.BEGINSTRING_FIX44, "MY_CompID", "THEIR_CompID" ); Session session = Session.lookupSession( sessionID ); if (session == null) { logger.log( Level.WARNING, "No such session: " + sessionID ); } Code to send a Quote message... QuoteID quoteID = new QuoteID( getNextQuoteID() ); // You will need unique QuoteID values Quote message = new Quote( quoteID ); // SETUP any additional fields message.set( new SecurityID( "MY_CUSIP" ) ); message.set( new SecurityIDSource( SecurityIDSource.CUSIP ) ); if (session.isLoggedOn()) { session.send( message ); } else { logger.log( Level.WARNING, "FIX session is not logged on" ); } This code handle Quote messages... @Override public void onMessage(Quote message, SessionID sessionID) throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue { final String msgTypeName = message.getClass().getSimpleName(); final Header header = (Header) message.getHeader(); logger.log( Level.INFO, "Incoming " + msgTypeName + " message (" + header.getMsgSeqNum() + ") from session (" + sessionID + "); Message (" + message + ")" ); } You can override as many of the onMessage methods for each of message class as you wish. That is about all you need to perform your test. Regards - Tommy On Jan 12, 2011, at 11:06 AM, Sandhu, Baljeet wrote: > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > > > Hi > > Thanks for responding. > > The 'SocketTcpNoDelay' seems to have a default value of Y, according to > the user guide. > I am posting some relevant code. Maybe you can spot a problem. > > ============== Initiator ============== > > On the client side (initiator) we have MessageListener and MessageSender > abstractions. > > ----Message Listener---- > > @Override > public final void onMessage(SessionID sessionId, Message message) { > log.trace(sessionId + " >> " + message); > try { > crack(message, sessionId); > } catch (Exception e) { > log.debug(e.getMessage(), e); > throw new FixException(e); > } > } > > @Override > public void onMessage(Quote quote, @SuppressWarnings("unused") > SessionID sessionId) { > try { > FiQuote fiQuote = messageCodec.decodeQuote(quote); > log.info(addInfo(fiQuote.getId(), "FI Quote received", > fiQuote.getUserId())); > > quoteResponseListener.onQuote(fiQuote); > // This goes into a workflow where we lock the quote > object > // inorder to process it > } catch (Exception e) { > throw new FixException(e); > } > } > > > ----MessageSender---- > > @Override > public final void send(Message message) { > if (sessionId == null) { > throw new FixSessionNotInitializedException("FIX session is > not established for " + cmdirectId > + ". Verify that FIX server is up and running"); > } > if(log.isDebugEnabled()){ > log.debug(sessionId + " << " + message); > } > try { > Session.sendToTarget(message, sessionId); > } catch (Exception e) { > log.debug(e.getMessage(), e); > throw new FixException(e); > } > } > > -----Config----- > > [DEFAULT] > ConnectionType=initiator > BeginString=FIX.4.4 > HeartBtInt=30 > ReconnectInterval=5 > SenderCompID=TEST_CLIENT > > [SESSION] > CMDirectID=RFQ_SESSION > TargetCompID=TEST_SERVER > ResetOnLogout=Y > SendResetSeqNumFlag=Y > ResetOnLogon=Y > TimeZone=America/New_York > EndTime=00:00:00 > StartTime=00:00:00 > SocketConnectHost=ulcmdrd1.devfg.rbc.com > SocketConnectPort=9876 > PersistMessages=Y > UseDataDictionary=Y > DataDictionary=FIX44_Eddie.xml > ValidateUserDefinedFields=Y > SocketSendBufferSize=32768 > SocketReceiveBufferSize=32768 > > ============== Acceptor ============== > > public void fromApp(quickfix.Message message, SessionID sessionId) > throws FieldNotFound, IncorrectTagValue, UnsupportedMessageType { > log.info("Got from FIX client: " + sessionId + " >>" + > formatMessage(message, sessionId)); > taskExecutor.execute(new ProcessTask(message, sessionId)); > } > > @Override > public void onMessage(QuoteRequest quoteRequest, SessionID > sessionId) { > try { > Quote quote = createQuote(quoteRequest); > log.debug("Sending Quote: " + sessionId + " << " + quote); > Session.sendToTarget(quote, sessionId); > } catch (Exception e) { > handleErrors(e); > } > } > > private class ProcessTask implements Runnable { > private final Message message; > private final SessionID sessionId; > > public ProcessTask(Message message, SessionID sessionId) { > this.message = message; > this.sessionId = sessionId; > } > > @Override public void run() { > onMessage(message, sessionId); > } > } > > -----Config----- > > [DEFAULT] > ConnectionType=acceptor > BeginString=FIX.4.4 > SenderCompID=TEST_SERVER > DataDictionary=FIX44_Eddie.xml > > TimeZone=America/New_York > StartTime=00:00:00 > EndTime=00:00:00 > SocketAcceptPort=9876 > > PersistMessages=Y > SocketSendBufferSize=32768 > SocketReceiveBufferSize=32768 > > > Thanks heaps > Baljeet > > -----Original Message----- > From: th...@co... [mailto:th...@co...] > Sent: 2011, January, 11 6:47 PM > To: qui...@li... > Subject: Re: [Quickfixj-users] Performance hints > > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > > > > > ________________________________________ > > This E-Mail (including any attachments) may contain privileged or confidential information. It is intended only for the addressee(s) indicated above. > > The sender does not waive any of its rights, privileges or other protections respecting this information. > > Any distribution, copying or other use of this E-Mail or the information it contains, by other than an intended recipient, is not sanctioned and is prohibited. > > If you received this E-Mail in error, please delete it and advise the sender (by return E-Mail or otherwise) immediately. > > This E-Mail (including any attachments) has been scanned for viruses. > > It is believed to be free of any virus or other defect that might affect any computer system into which it is received and opened. > > However, it is the responsibility of the recipient to ensure that it is virus free. > > The sender accepts no responsibility for any loss or damage arising in any way from its use. > > E-Mail received by or sent from RBC Capital Markets is subject to review by Supervisory personnel. > > Such communications are retained and may be produced to regulatory authorities or others with legal rights to the information. > > IRS CIRCULAR 230 NOTICE: TO COMPLY WITH U.S. TREASURY REGULATIONS, WE ADVISE YOU THAT ANY U.S. FEDERAL TAX ADVICE INCLUDED IN THIS COMMUNICATION IS NOT INTENDED OR WRITTEN TO BE USED, AND CANNOT BE USED, TO AVOID ANY U.S. FEDERAL TAX PENALTIES OR TO PROMOTE, MARKET, OR RECOMMEND TO ANOTHER PARTY ANY TRANSACTION OR MATTER. > > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Quickfixj-users mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfixj-users |