Thread: [Quickfix-users] Create Logon Message
Brought to you by:
orenmnero
From: bornlibra23 <awa...@ns...> - 2009-08-04 14:44:03
|
Hello People Can somebody help me with creating a logon message manually while disabling the auto logon feature. I need to have application control over logon. Thanks bornlibra23 -- View this message in context: http://www.nabble.com/Create-Logon-Message-tp24809985p24809985.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |
From: EclipseCap <tob...@ec...> - 2009-08-04 15:12:31
|
Greetings, I am currently working on something kind of like that. I am using c# if that makes any difference for you. I am going to post the code from my app. It will not compile as it is missing a lot of the classes behind it. But I think if you look at the examples provided and then my code you should be able to piece it together. The trick is to do all of your setup during the construction, but not to start the initiator until you have all of your sessions setup. So once all of the setup is completed you simply execute m_Initiator.start() and it should try to startup any connections you have readied. In the EnableSession function there is a line Enable.logon() and Enable.logout(). You can call those before m_Initiator.start() fires. If you call .logout before it .start() then the logged out connection won't even try. Logon and Logout are kind of bad names really. logon/logout is more like a state. While in logon it will try to connect forever until it succeeds not just try once and return. This code is the constructor code. I wrote it to create a list of sessions based upon rows in a database rather than a setup file. m_Settings = new SessionSettings(); //------------------------------------------------------------------------------------- // Get all of the default values set. Then we build each session. //------------------------------------------------------------------------------------- QuickFix.Dictionary defaultDic = m_Settings.get(); defaultDic.setString("ConnectionType", "initiator"); defaultDic.setString("HeartBtInt", "30"); defaultDic.setString("ReconnectInterval", "1"); defaultDic.setString("FileStorePath", "store"); defaultDic.setString("FileLogPath", "log"); defaultDic.setString("StartTime", "00:00:00"); defaultDic.setString("EndTime", "00:00:00"); defaultDic.setString("UseDataDictionary", "N"); defaultDic.setString("HttpAcceptPort", "8080"); m_Settings.set(defaultDic); foreach(SessionData sessionData in m_Hub.DataManager.Sessions.SessionDataList) { //--------------------------------------------------------------------------------- // Setting this session id will fire off session data callbacks. //--------------------------------------------------------------------------------- sessionData.SessionID = BuildSession(sessionData); } m_Application = new FixApplication(); //---------------------------------------------------------------------------------------- // You can probably skip this as it is all about setting up the callbacks from FIX. //---------------------------------------------------------------------------------------- m_Application.FIXLoginStatusUpdateEvent += new FIXLoginStatusEventHandler(Application_LoginStatusUpdate); m_Application.FIXOrderStatusUpdateEvent += new FIXOrderStatusUpdate(Application_FIXOrderStatusUpdate); m_Application.FIXOrderFillUpdateEvent += new FIXOrderFillUpdate(Application_FIXOrderFillUpdate); m_Application.FIXOrderNewUpdateEvent += new FIXOrderNewUpdate(Application_FIXOrderNewUpdate); m_Application.FIXOrderCancelUpdateEvent += new FIXOrderCancelUpdate(Application_FIXOrderCancelUpdate); m_Application.FIXCancelRejectUpdateEvent += new FIXCancelRejectUpdate(Application_FIXCancelRejectUpdateEvent); //---------------------------------------------------------------------------------------- m_StoreFactory = new FileStoreFactory(m_Settings); m_MessageFactory = new DefaultMessageFactory(); m_Initiator = new SocketInitiator(m_Application, m_StoreFactory, m_Settings, m_MessageFactory); //------------------------------------------------------------------------------------- // Enable/Disable sessions. //------------------------------------------------------------------------------------- foreach (SessionData sessionData in m_Hub.DataManager.Sessions.SessionDataList) { EnableSession(sessionData.SessionID, sessionData.Enabled); } private bool EnableSession(string sessionID, bool sessionEnable) { bool retval = false; SessionID ID = new SessionID(); ID.fromString(sessionID.ToString()); if (Session.doesSessionExist(ID) == true) { retval = true; Session Enable = Session.lookupSession(ID); if (sessionEnable == true) { Enable.logon(); } else { Enable.logout(); } } return retval; } public string BuildSession(SessionData sessionData) { QuickFix.Dictionary defaultDic = m_Settings.get(); //------------------------------------------------------------------------------------- // Iterate through the datamanager and build our list of sessions. //------------------------------------------------------------------------------------- SessionID sID = new SessionID(new BeginString(sessionData.FixVersion), new SenderCompID(sessionData.SenderCompID), new TargetCompID(sessionData.TargetCompID)); //------------------------------------------------------------------------------------- // Add all of our session values as well. //------------------------------------------------------------------------------------- foreach (int TagID in sessionData.SessionConnection.SessionValues.Keys) { SessionValue sessionValue = sessionData.SessionConnection.SessionValues[TagID]; if(sessionValue != null) defaultDic.setString(sessionValue.Tag, sessionValue.Value); } m_Settings.set(sID, defaultDic); return sID.toString(); } Feel free to send me a message if you have questions. I can't say I am expert but at least I'm willing to help. -- View this message in context: http://www.nabble.com/Create-Logon-Message-tp24809985p24810491.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |
From: bornlibra23 <awa...@ns...> - 2009-08-06 05:31:39
|
Hello EclipseCap Greetings, Thanks For The Heads Up. Doesnt Quickfix provide a way to disable autologon? That is as soon as a session is created it will not try to logon. That is a quite a lot of code you provided. Also is there a callback that is used to notify of errors during logon? Thanks bornlibra23 -- View this message in context: http://www.nabble.com/Create-Logon-Message-tp24809985p24840416.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |
From: bornlibra23 <awa...@ns...> - 2009-08-06 11:27:33
|
I have another question. How can I have callbacks delivered & executed in a separate thread than the one that created the quickfix objects? Thanks bornlibra23 -- View this message in context: http://www.nabble.com/Create-Logon-Message-tp24809985p24844703.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |
From: EclipseCap <tob...@ec...> - 2009-08-06 13:50:34
|
A lot of that stuff is language dependent and not really a QFIX thing. For starters I believe QFix should run within its own thread as part of its startup process. So when a callback fires from the QFix side it is on the QFix's thread. In C# when going to call code on my side I do a this.BeginInvoke which should put the function you are going to call on the message queue of the thread on your side. This only applies for C# so if you are using another language I can't be of much help. public void FIXOrderFillUpdate(FIXOrderFillMessage FillMessage) { if (delFIXOrderFillUpdate != null && InvokeRequired == true) { this.BeginInvoke(delFIXOrderFillUpdate, FillMessage); } } delFIXOrderFillUpdate is a delegate I created earlier. bornlibra23 wrote: > > I have another question. How can I have callbacks delivered & executed in > a separate thread than the one that created the quickfix objects? > Thanks > bornlibra23 > -- View this message in context: http://www.nabble.com/Create-Logon-Message-tp24809985p24846833.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |
From: bornlibra23 <awa...@ns...> - 2009-08-10 12:31:59
|
Thanks EclipseCap I am almost through with the login process. The only thing I am unable to figure out is why is the engine sending multiple login messages? 20090810-10:38:45 : Connecting to 172.20.23.44 on port 9651 20090810-10:38:45 : Initiated logon request 20090810-10:38:47 : Received logout request 20090810-10:38:47 : Sending logout response 20090810-10:38:47 : Disconnecting 20090810-10:38:47 : Logon state is not valid for message Thanks bornlibra23 -- View this message in context: http://www.nabble.com/Create-Logon-Message-tp24809985p24898755.html Sent from the QuickFIX - User mailing list archive at Nabble.com. |