|
From: Tommy H. <th...@bo...> - 2007-05-11 03:45:13
|
T.S., I found myself asking similar questions when I started with QFJ a few weeks ago. My approach was to create 2 applications that communicate with one another and see what happened. This approach gave me great insight into the way QFJ works. You can create as many sessions as you want between the two apps. Do not be uneasy with the settings file; it actually works much better than you might think. Session(s) are created for each entry in the settings file. Each session defined, based on its type of either initiator or acceptor, is created when you call the corresponding start() method. Your application is actually not "single" threaded. The start() method runs a separate thread from your main one. This thread calls back your fromApp() method when a message is received (BTW, I would use the message cracker crack() method in fromApp() as the documentation suggests). All you have to do after calling the start () method(s) is block (e.g. wait() or sleep(), in a loop if preferred). The "threaded" approach is referring to one thread per session as opposed to one for all. This requires you to make your callback method(s) and supporting code thread safe, but allows for greater throughput and CPU utilization. I hope that helps. -Tommy On May 10, 2007, at 3:34 PM, t.s. wrote: > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > Hello everyone, > > It's me again :) Here's the outline of the code so far > ... > public static void main(String[] args) throws Exception { > String filename = "config.cfg"; > > Application application = new Main(); > SessionSettings settings = new SessionSettings( > new FileInputStream(filename)); > > MessageStoreFactory storeFactory = new FileStoreFactory(settings); > LogFactory logFactory = new FileLogFactory(settings); > MessageFactory messageFactory = new DefaultMessageFactory(); > > Initiator initiator = new SocketInitiator ( application, > storeFactory, > settings, logFactory, messageFactory); > > initiator.start(); > //1. create a QuoteRequest object > //2. init fields > //3. send QuoteRequest > //4. how to receive quotes ? via fromApp() ? > //5. disconnect/housekeeping > initiator.stop(); > } > ... > > I have several questions at this point: > 1. How does QuickFix negotiate login ? Couldn't find anything on the > subject in the documentation. > > 2. If i understand correctly, we're supposed to get messages via the > fromApp() event, (see #4 in code above), but I'm not sure how the > program flow should work, since this is a single threaded code. Do i > have to add a busy loop somewhere, like: > ... > initiator.start(); > sendSomeMessageToTheOtherSide(); > while (flag == 0) do { waitaround() }; //catch msg via fromApp(); > disconnectAndCleanup(); > initiator.stop(); > ... > > 3. I managed to scrape together a configuration file from the docs to > use with my code, but i feel a bit uneasy about the approach. Is the > config file mandatory ? Can't i just set the settings via code ? > > 4. In the code above, i think it's assumed that quickfix/j will > create a > default session for my use, but what to do when we need to use more > than > one? (probably a bit too advanced for me at this point, and sorry if > this is a RTFM question). > > 5. Still related to question #3 and #4, a settings/config file can > define multiple session parameter, how do we specify which one to > use? I > can't see how these things work together. For example, from the > code above, > ... > SessionSettings settings = new SessionSettings( > new FileInputStream(filename)); > ... followed by ... > Initiator initiator = new SocketInitiator (application, > storeFactory, > settings, logFactory, messageFactory); > ... > So initiator is initiated by the settings file, but if the settings > file > have multiple sessions, how do quickfixj tell which one to use? > > Thank you very much in advance, > Regards, > t.s. > > PS: Found some issues with the documentation... Where should i > report this? > > 1. In the 'sending messages' chapter, the following source code is > given > in the last section, the 'Most Type Safe' one. > ... > void sendOrderCancelRequest() > { > quickfix.fix41.OrderCancelRequest message( > new OrigClOrdID("123"), > new ClOrdID("321"), > new Symbol("LNUX"), > new Side(Side.BUY)); > > message.set(new Text("Cancel My Order!")); > Session.sendToTarget(message, "TW", "TARGET"); > } > ... > I'm having problem with the line that creates the message object, > since > it doesn't even look like valid java code. I was guessing that it > meant > something like : > ... > OrderCancelRequest ocr = new OrderCancelRequest(blah blah); > ... > but it turns out that the constructor has no parameter. > > 2. There's a small typo at > http://www.quickfixj.org/quickfixj/usermanual/usage/configuration.html >> [DEFAULT] >> ConnectionType=initator <<<< HERE >> ReconnectInterval=60 > The usermanual distributed with the latest quickfixj appeared to have > fixed this. > > 3. Earlier, i keep getting problems with NoClassDefFoundError > Exceptions, problem solved after including the JARs in \lib > directory in > my project (using netbeans, btw). Maybe this should be pointed out in > the documentation ? > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Quickfixj-users mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfixj-users > |