Settings for sessions. Settings are grouped by FIX version and target ID There is also a default settings that is inherited by the session-specific sections.
Beispiel #1
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("usage: SimpleAcceptor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                Application app = new SimpleAcceptorApp();
                MessageStoreFactory storeFactory = new FileStoreFactory(settings);
                LogFactory logFactory = new FileLogFactory(settings);
                IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #2
0
    public void SetUp()
    {
        application = new ApplicationImpl();
        SessionSettings settings = new SessionSettings( "c:\\development\\quickfix\\test\\cfg\\at_client.cfg" );
        MessageStoreFactory messageStoreFactory =
            new MemoryStoreFactory();
        QuickFix42.MessageFactory messageFactory = new QuickFix42.MessageFactory();

        initiator = new SocketInitiator
            (application, messageStoreFactory, settings, messageFactory);

        server = new Process();
        server.StartInfo.FileName = "c:\\development\\quickfix\\test\\debug\\at\\at";
        server.StartInfo.Arguments = "-f c:\\development\\quickfix\\test\\cfg\\at.cfg";
        server.Start();

        Thread quickFixThread = new Thread(RunThread);
        quickFixThread.Start();

        for(int i = 0;i < 50;++i)
        {
            if(application.isLoggedOn())
            {
                break;
            }
            Thread.Sleep(1000);
        }
        if(!application.isLoggedOn())
        {
            throw new Exception();
        }
    }
Beispiel #3
0
        public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
        {
            settings_ = settings;

            HashSet <SessionID> definedSessions = settings.GetSessions();

            if (0 == definedSessions.Count)
            {
                throw new ConfigError("No sessions defined");
            }

            SessionFactory factory = new SessionFactory(app, storeFactory, logFactory, messageFactory);

            foreach (SessionID sessionID in definedSessions)
            {
                Dictionary dict = settings.Get(sessionID);
                if ("initiator".Equals(dict.GetString(SessionSettings.CONNECTION_TYPE)))
                {
                    sessionIDs_.Add(sessionID);
                    sessions_[sessionID] = factory.Create(sessionID, dict);
                    SetDisconnected(sessionID);
                }
            }

            if (0 == sessions_.Count)
            {
                throw new ConfigError("No sessions defined for initiator");
            }
        }
        private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(SessionSettings settings, SessionID sessionID)
        {
            QuickFix.Dictionary dict      = settings.Get(sessionID);
            int            port           = System.Convert.ToInt32(dict.GetLong(SessionSettings.SOCKET_ACCEPT_PORT));
            SocketSettings socketSettings = new SocketSettings();

            IPEndPoint socketEndPoint;

            if (dict.Has(SessionSettings.SOCKET_ACCEPT_HOST))
            {
                string      host  = dict.GetString(SessionSettings.SOCKET_ACCEPT_HOST);
                IPAddress[] addrs = Dns.GetHostAddresses(host);
                socketEndPoint = new IPEndPoint(addrs[0], port);
                // Set hostname (if it is not already configured)
                socketSettings.ServerCommonName = socketSettings.ServerCommonName ?? host;
            }
            else
            {
                socketEndPoint = new IPEndPoint(IPAddress.Any, port);
            }

            socketSettings.Configure(dict);


            AcceptorSocketDescriptor descriptor;

            if (!socketDescriptorForAddress_.TryGetValue(socketEndPoint, out descriptor))
            {
                descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict);
                socketDescriptorForAddress_[socketEndPoint] = descriptor;
            }

            return(descriptor);
        }
        private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(SessionSettings settings, SessionID sessionID)
        {
            QuickFix.Dictionary dict      = settings_.Get(sessionID);
            int            port           = System.Convert.ToInt32(dict.GetLong(SessionSettings.SOCKET_ACCEPT_PORT));
            SocketSettings socketSettings = new SocketSettings();

            IPEndPoint socketEndPoint;

            if (dict.Has(SessionSettings.SOCKET_ACCEPT_HOST))
            {
                string      host  = dict.GetString(SessionSettings.SOCKET_ACCEPT_HOST);
                IPAddress[] addrs = Dns.GetHostAddresses(host);
                socketEndPoint = new IPEndPoint(addrs[0], port);
            }
            else
            {
                socketEndPoint = new IPEndPoint(IPAddress.Any, port);
            }

            if (dict.Has(SessionSettings.SOCKET_NODELAY))
            {
                socketSettings.SocketNodelay = dict.GetBool(SessionSettings.SOCKET_NODELAY);
            }

            AcceptorSocketDescriptor descriptor;

            if (!socketDescriptorForAddress_.TryGetValue(socketEndPoint, out descriptor))
            {
                descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict);
                socketDescriptorForAddress_[socketEndPoint] = descriptor;
            }

            return(descriptor);
        }
Beispiel #6
0
  static void Main( string[] args )
  {
    if ( args.Length != 1 )
    {
      Console.WriteLine( "usage: executor_csharp FILE." );
      return ;
    }

    try
    {
      SessionSettings settings = new SessionSettings( args[ 0 ] );
      Application application = new Application();
      FileStoreFactory storeFactory = new FileStoreFactory( settings );
      ScreenLogFactory logFactory = new ScreenLogFactory( settings );
      MessageFactory messageFactory = new DefaultMessageFactory();
      SocketAcceptor acceptor
        = new SocketAcceptor( application, storeFactory, settings, logFactory, messageFactory );

      acceptor.start();
      Console.WriteLine("press <enter> to quit");
      Console.Read();
      acceptor.stop();
    }
    catch ( Exception e )
    {
      Console.WriteLine( e );
    }
  }
Beispiel #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is only an example program, meant to be used with the TradeClient example.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                Console.WriteLine("usage: Executor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                IApplication executorApp = new Executor();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = new FileLogFactory(settings);
                ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(executorApp, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is for evaluating new QF/n builds and features.");
            Console.WriteLine("It's designed to communicate with PilotInitiator44.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                Console.WriteLine("usage: PilotAcceptorr44 CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                IApplication myApp = new PilotAcc44App();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = new FileLogFactory(settings);
                ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(myApp, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is for evaluating new QF/n builds and features.");
            Console.WriteLine("It's designed to communicate with PilotAcceptor44.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                System.Console.WriteLine("usage: PilotInitiator44.exe CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            string file = args[0];

            try
            {
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings(file);
                PilotInit44App myApp = new PilotInit44App();
                QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                QuickFix.ILogFactory logFactory = new QuickFix.FileLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(myApp, storeFactory, settings, logFactory);

                initiator.Start();
                myApp.Run();
                initiator.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
Beispiel #10
0
 private void Init()
 {
     this.settings            = new QuickFix.SessionSettings(this.settingFile);
     this.messageStoreFactory = new QuickFix.FileStoreFactory(this.settings);
     this.logFactory          = new QuickFix.FileLogFactory(this.settings);
     this.messageFactory      = new QuickFix42.MessageFactory();
     this.socketInitiator     = new QuickFix.SocketInitiator(this, this.messageStoreFactory, this.settings, this.logFactory, this.messageFactory);
 }
Beispiel #11
0
        public void initFix()
        {
            settings = new QuickFix.SessionSettings(@"c:\s2trading\zmqhubresource\tradeclient.cfg");
            myApp    = new FixClient();
            FileStoreFactory storeFactory = new FileStoreFactory(settings);
            FileLogFactory   logFactory   = new FileLogFactory(settings);

            initiator = new QuickFix.Transport.SocketInitiator(myApp, storeFactory, settings, logFactory);
            initiator.Start();
        }
Beispiel #12
0
 private void CreateSessions(SessionSettings settings, SessionFactory sessionFactory)
 {
     sessionFactory_ = sessionFactory;
     settings_       = settings;
     foreach (SessionID sessionID in settings.GetSessions())
     {
         QuickFix.Dictionary dict = settings.Get(sessionID);
         CreateSession(sessionID, dict);
     }
 }
Beispiel #13
0
 public void Close()
 {
     //this.socketInitiator.stop();
     this.ssnid               = null;
     this.socketInitiator     = null;
     this.messageStoreFactory = null;
     this.settings            = null;
     this.logFactory          = null;
     this.messageFactory      = null;
 }
        public void Connect(IApplication application)
        {
            var settings = new SessionSettings("session.config");
            var myApp = application;
            var storeFactory = new FileStoreFactory(settings);
            var logFactory = new FileLogFactory(settings);

            initiator = new SocketInitiator(myApp, storeFactory, settings, logFactory);

            initiator.Start();
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.WriteLine("usage: AcceptanceTest CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            FileLog debugLog = new FileLog("log", new SessionID("AT", "Application", "Debug")); 
            ThreadedSocketAcceptor acceptor = null;
            try
            {
                ATApplication testApp = new ATApplication(debugLog);
                testApp.StopMeEvent += new System.Action(delegate() { _stopMe = true; });
                
                SessionSettings settings = new SessionSettings(args[0]);
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = null;
                if (settings.Get().Has("Verbose") && settings.Get().GetBool("Verbose"))
                    logFactory = new FileLogFactory(settings);
                acceptor = new ThreadedSocketAcceptor(testApp, storeFactory, settings, logFactory);

                acceptor.Start();
                while (true)
                {
                    System.Console.WriteLine("o hai "+System.DateTime.Now.ToString());
                    System.Threading.Thread.Sleep(1000);

                    // for tests of logout
                    if (_stopMe)
                    {
                        // this doesn't seem to work
                        // after stop, it doesn't seem to start up again
                        /*
                        acceptor.Stop();
                        Thread.Sleep(5 * 1000);
                        _stopMe = false;
                        acceptor.Start();
                         */
                    }
                }
            }
            catch (System.Exception e)
            {
                debugLog.OnEvent(e.ToString());
            }

            finally
            {
                if(acceptor != null)
                    acceptor.Stop();
            }
            
        }
Beispiel #16
0
        public FileStore(SessionID sessionID, SessionSettings settings)
        {
            string path = settings.Get(sessionID).GetString(SessionSettings.FILE_STORE_PATH);

            var encoding = settings.Get(sessionID).Has(SessionSettings.ENCODING)
                ? Encoding.GetEncoding(settings.Get(sessionID).GetString(SessionSettings.ENCODING))
                : SessionFactory.DefaultEncoding;

            Init(path, sessionID, encoding);
            open();
        }
 public ThreadedSocketAcceptor(SessionFactory sessionFactory, SessionSettings settings)
 {
     try
     {
         CreateSessions(settings, sessionFactory);
     }
     catch (System.Exception e)
     {
         throw new ConfigError(e.Message, e);
     }
 }
Beispiel #18
0
        public ODBCLog(SessionSettings settings, SessionID sessionID)
        {
            _sessionID       = sessionID;
            _sessionSettings = settings;

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_USER))
            {
                _user = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_USER);
            }

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_PASSWORD))
            {
                _pwd = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_PASSWORD);
            }

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_INCOMING_TABLE))
            {
                incomingTable = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_INCOMING_TABLE);
            }

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_INCOMING_BACKUP_TABLE))
            {
                incomingBackupTable = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_INCOMING_BACKUP_TABLE);
            }

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_OUTGOING_TABLE))
            {
                outgoingTable = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_OUTGOING_TABLE);
            }

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_OUTGOING_BACKUP_TABLE))
            {
                outgoingBackupTable = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_OUTGOING_BACKUP_TABLE);
            }

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_EVENT_TABLE))
            {
                eventTable = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_EVENT_TABLE);
            }

            if (_sessionSettings.Get(sessionID).Has(SessionSettings.ODBC_LOG_EVENT_BACKUP_TABLE))
            {
                eventBackupTable = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_EVENT_BACKUP_TABLE);
            }

            _connectionString = _sessionSettings.Get(sessionID).GetString(SessionSettings.ODBC_LOG_CONNECTION_STRING);


            OdbcConnectionStringBuilder sb = new OdbcConnectionStringBuilder(_connectionString);

            sb["UID"] = _user;
            sb["PWD"] = _pwd;
            OdbcConnection odbc = GetODBCConnection();
        }
Beispiel #19
0
 public ThreadedSocketAcceptor(SessionFactory sessionFactory, SessionSettings settings)
 {
     try
     {
         CreateSessions(settings, sessionFactory);
     }
     catch (System.Exception e)
     {
         throw new ConfigError(e.Message, e);
     }
 }
        public AbstractInitiator(
            IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
        {
            _app = app;
            _storeFactory = storeFactory;
            _settings = settings;
            _logFactory = logFactory;
            _msgFactory = messageFactory;

            HashSet<SessionID> definedSessions = _settings.GetSessions();
            if (0 == definedSessions.Count)
                throw new ConfigError("No sessions defined");
        }
Beispiel #21
0
        /// <summary>
        /// Connects/Starts a client
        /// </summary>
        public bool Start()
        {
            try
            {
                if (this._initiator == null)
                {
                    PopulateFixSettings();

                    QuickFix.SessionSettings      settings       = new QuickFix.SessionSettings(this._fixSettingsFile);
                    IApplication                  application    = this;
                    QuickFix.FileStoreFactory     storeFactory   = new QuickFix.FileStoreFactory(settings);
                    QuickFix.FileLogFactory       logFactory     = new QuickFix.FileLogFactory(settings);
                    QuickFix.IMessageStoreFactory messageFactory = new QuickFix.FileStoreFactory(settings);

                    this._initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);

                    this._initiator.Start();

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info("Integral Data Client Started.", _type.FullName, "Start");
                    }
                }
                else
                {
                    if (!this._initiator.IsStopped)
                    {
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info("Integral Data Client Already Started.", _type.FullName, "Start");
                        }
                    }
                    else
                    {
                        this._initiator.Start();
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info("Integral Data Client Started.", _type.FullName, "Start");
                        }
                    }
                }

                return(true);
            }
            catch (Exception exception)
            {
                Logger.Error(exception.ToString(), _type.FullName, "Start");
            }
            return(false);
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            string file = "server.cfg";

            SessionSettings settings = new SessionSettings(file);
            IApplication executorApp = new Server();
            IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
            ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(executorApp, storeFactory, settings);

            acceptor.Start();
            Console.WriteLine("press <enter> to quit");
            Console.Read();
            acceptor.Stop();
        }
        private void CreateSessions(SessionSettings settings, SessionFactory sessionFactory)
        {
            sessionFactory_ = sessionFactory;
            foreach (SessionID sessionID in settings.GetSessions())
            {
                QuickFix.Dictionary dict = settings.Get(sessionID);
                AddSession(sessionID, dict);
            }

            if (0 == socketDescriptorForAddress_.Count)
            {
                throw new ConfigError("No acceptor sessions found in SessionSettings.");
            }
        }
Beispiel #24
0
        public AbstractInitiator(
            IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
        {
            _app          = app;
            _storeFactory = storeFactory;
            _settings     = settings;
            _logFactory   = logFactory ?? new NullLogFactory();
            _msgFactory   = messageFactory ?? new DefaultMessageFactory();

            HashSet <SessionID> definedSessions = _settings.GetSessions();

            if (0 == definedSessions.Count)
            {
                throw new ConfigError("No sessions defined");
            }
        }
Beispiel #25
0
        public void setup()
        {
            sessionID = new QuickFix.SessionID("FIX.4.2", "SENDERCOMP", "TARGETCOMP");
            Wipe();

            QuickFix.Dictionary config = new QuickFix.Dictionary();
            config.SetString(QuickFix.SessionSettings.CONNECTION_TYPE, "initiator");
            config.SetString(QuickFix.SessionSettings.DATABASE_STORE_CONNECTION_STRING, connectionString);

            settings = new QuickFix.SessionSettings();
            settings.Set(sessionID, config);
            factory = new QuickFix.DatabaseStoreFactory(settings);
            settings.Set(config);

            store = (QuickFix.DatabaseStore)factory.Create(sessionID, new NullLog());
        }
Beispiel #26
0
        public void Load()
        {
            string configuration = new System.Text.StringBuilder()
                .AppendLine("[DEFAULT]")
                .AppendLine("ConnectionType=initiator")
                .AppendLine("BeginString=FIX.4.0")
                .AppendLine("Value=4")
                .AppendLine("Empty=")
                .AppendLine(partialConfiguration.ToString())
                .ToString();
            SessionSettings settings = new SessionSettings(new System.IO.StringReader(configuration));

            SessionID session1 = new SessionID("FIX.4.2", "ISLD", "TW");
            SessionID session2 = new SessionID("FIX.4.1", "ISLD", "WT");
            SessionID session3 = new SessionID("FIX.4.0", "ARCA", "TW");
            SessionID session4 = new SessionID("FIX.4.0", "ARCA", "WT");
            SessionID session5 = new SessionID("FIX.4.0", "NYSE", "TW", "QUAL1");
            SessionID session6 = new SessionID("FIX.4.0", "NYSE", "TW", "QUAL2");

            Assert.That(settings.Get().GetString( "Empty" ), Is.EqualTo("") );

            Assert.That(settings.Get().GetLong( "Value" ), Is.EqualTo(4) );
            Assert.That(settings.Get(session1).GetLong("Value"), Is.EqualTo(1));
            Assert.That(settings.Get(session2).GetLong("Value"), Is.EqualTo(2));
            Assert.That(settings.Get(session3).GetLong("Value"), Is.EqualTo(3));
            Assert.That(settings.Get(session4).GetLong("Value"), Is.EqualTo(4));
            Assert.That(settings.Get(session5).GetLong("Value"), Is.EqualTo(5));
            Assert.That(settings.Get(session6).GetLong("Value"), Is.EqualTo(6));

            // case insensitivity
            Assert.That(settings.Get().GetLong("value"), Is.EqualTo(4));
            Assert.That(settings.Get(session1).GetLong("value"), Is.EqualTo(1));
            Assert.That(settings.Get(session2).GetLong("value"), Is.EqualTo(2));
            Assert.That(settings.Get(session3).GetLong("value"), Is.EqualTo(3));
            Assert.That(settings.Get(session4).GetLong("value"), Is.EqualTo(4));
            Assert.That(settings.Get(session5).GetLong("value"), Is.EqualTo(5));
            Assert.That(settings.Get(session6).GetLong("value"), Is.EqualTo(6));

            Assert.That(settings.Get().GetLong("VALUE"), Is.EqualTo(4));
            Assert.That(settings.Get(session1).GetLong("VALUE"), Is.EqualTo(1));
            Assert.That(settings.Get(session2).GetLong("VALUE"), Is.EqualTo(2));
            Assert.That(settings.Get(session3).GetLong("VALUE"), Is.EqualTo(3));
            Assert.That(settings.Get(session4).GetLong("VALUE"), Is.EqualTo(4));
            Assert.That(settings.Get(session5).GetLong("VALUE"), Is.EqualTo(5));
            Assert.That(settings.Get(session6).GetLong("VALUE"), Is.EqualTo(6));
        }
Beispiel #27
0
        static void Main(string[] args)
        {
            var settingsFile = "FixAtServer.cfg";
            if (args.Length >= 1)
            {
                settingsFile = args[0];
            }

            Console.WriteLine("Starting server ...");
            try
            {
                var settings = new SessionSettings(settingsFile);
                var server = new ServerApplication(Console.WriteLine);
                var storeFactory = new FileStoreFactory(settings);
                var logFactory = new FileLogFactory(settings);
                var acceptor = new ThreadedSocketAcceptor(server,
                                                          storeFactory,
                                                          settings,
                                                          logFactory);

                acceptor.Start();
                Console.WriteLine("Server started");
                Console.WriteLine("Press Ctrl-C to quit");
                // TODO A better stop mechanism!

                // http://stackoverflow.com/questions/177856/how-do-i-trap-ctrl-c-in-a-c-sharp-console-app
                Console.CancelKeyPress += (sender, e) =>
                    {
                        Console.WriteLine("Stopping server ...");
                        acceptor.Stop();
                        server.Stop();
                        Console.WriteLine("Server stopped");
                    };

                while (true)
                {
                    System.Threading.Thread.Sleep(1000);
                }

            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e);
            }
        }
Beispiel #28
0
        /// <summary>
        /// Create a ThreadedSocketAcceptor
        /// </summary>
        /// <param name="application"></param>
        /// <param name="storeFactory"></param>
        /// <param name="settings"></param>
        /// <param name="logFactory">If null, a NullFactory will be used.</param>
        /// <param name="messageFactory">If null, a DefaultMessageFactory will be created (using settings parameters)</param>
        public ThreadedSocketAcceptor(
            IApplication application,
            IMessageStoreFactory storeFactory,
            SessionSettings settings,
            ILogFactory logFactory,
            IMessageFactory messageFactory)
        {
            logFactory     = logFactory ?? new NullLogFactory();
            messageFactory = messageFactory ?? new DefaultMessageFactory();
            SessionFactory sf = new SessionFactory(application, storeFactory, logFactory, messageFactory);

            try
            {
                CreateSessions(settings, sf);
            }
            catch (System.Exception e)
            {
                throw new ConfigError(e.Message, e);
            }
        }
        private void CreateSessions(SessionSettings settings)
        {
            foreach (SessionID sessionID in settings.GetSessions())
            {
                QuickFix.Dictionary dict = settings.Get(sessionID);
                string connectionType    = dict.GetString(SessionSettings.CONNECTION_TYPE);

                if ("acceptor".Equals(connectionType))
                {
                    AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(settings, sessionID);
                    Session session = sessionFactory_.Create(sessionID, dict);
                    descriptor.AcceptSession(session);
                    sessions_[sessionID] = session;
                }
            }

            if (0 == socketDescriptorForAddress_.Count)
            {
                throw new ConfigError("No acceptor sessions found in SessionSettings.");
            }
        }
Beispiel #30
0
        public ODBCStore(SessionID sessionId, string user, string password, string connectionString, SessionSettings settings)
        {
            _sessionID       = sessionId;
            _sessionSettings = settings;

            if (_sessionSettings.Get(_sessionID).Has(SessionSettings.ODBC_STORE_SESSION_TABLE))
            {
                sessions_table = _sessionSettings.Get(_sessionID).GetString(SessionSettings.ODBC_STORE_SESSION_TABLE);
            }

            if (_sessionSettings.Get(_sessionID).Has(SessionSettings.ODBC_STORE_MESSAGES_TABLE))
            {
                messages_table = _sessionSettings.Get(_sessionID).GetString(SessionSettings.ODBC_STORE_MESSAGES_TABLE);
            }

            _connectionString = connectionString;
            _user             = user;
            _pwd = password;

            PopulateCache();
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // FIX app settings and related
            var settings = new SessionSettings("C:\\initiator.cfg");

            // FIX application setup
            MessageStoreFactory storeFactory = new FileStoreFactory(settings);
            LogFactory logFactory = new FileLogFactory(settings);
            _client = new FixClient50Sp2(settings);

            IInitiator initiator = new SocketInitiator(_client, storeFactory, settings, logFactory);
            _client.Initiator = initiator;

            _client.OnProgress += _client_OnProgress;
            _client.LogonEvent += ClientLogonEvent;
            _client.MessageEvent += ClientMessageEvent;
            _client.LogoutEvent += ClientLogoutEvent;
            _client.OnMarketDataIncrementalRefresh += Client_OnMarketDataIncrementalRefresh;
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            try
            {
                QuickFix.SessionSettings           settings     = new QuickFix.SessionSettings("config_nossl.cfg");
                MarketDataApp                      application  = new MarketDataApp();
                QuickFix.IMessageStoreFactory      storeFactory = new QuickFix.FileStoreFactory(settings);
                QuickFix.ILogFactory               logFactory   = new NullLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator    = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);
                initiator.Start();

                System.Threading.Thread.Sleep(Int32.MaxValue);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Console.ReadLine();
            }
            Environment.Exit(1);
        }
Beispiel #33
0
 static void Main(string[] args)
 {
     try
     {
         QuickFix.SessionSettings           settings     = new QuickFix.SessionSettings("config/quickfix-client.cfg");
         MyQuickFixApp                      application  = new MyQuickFixApp();
         QuickFix.IMessageStoreFactory      storeFactory = new QuickFix.FileStoreFactory(settings);
         QuickFix.ILogFactory               logFactory   = new QuickFix.ScreenLogFactory(settings);
         QuickFix.Transport.SocketInitiator initiator    = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);
         initiator.Start();
         Console.ReadKey();
         initiator.Stop();
     }
     catch (System.Exception e)
     {
         Console.WriteLine(e.Message);
         Console.WriteLine(e.StackTrace);
         Console.ReadKey();
     }
     Environment.Exit(1);
 }
        private FixProxyServer()
        {
            quoteRequest = new QuoteRequest();
            FileStoreFactory mesStoreFact;
            DefaultMessageFactory mesFact;

            SessionSettings sets;
            try
            {
                sets = new SessionSettings(string.Format("{0}\\{1}",
                                                         ExecutablePath.ExecPath,
                                                         SessionSettingsParser.SessionSettingsFileName));
                SessionSettingsParser.Init(string.Format("{0}\\{1}",
                                                         ExecutablePath.ExecPath,
                                                         SessionSettingsParser.SessionSettingsFileName));
                app = new FixApplication();
                app.processMessageFromBroker += MessageDispatcher.ProcessMessageFromBroker;
                mesStoreFact = new FileStoreFactory(string.Format("{0}\\log",
                                                         ExecutablePath.ExecPath));
                mesFact = new DefaultMessageFactory();

                app.OnSessionLogon += AppOnSessionLogon;
            }
            catch (Exception ex)
            {
                Logger.Error("SocketInitiator pre-create error", ex);
                throw;
            }

            try
            {
                initiator = new SocketInitiator(app, mesStoreFact, sets, mesFact);
            }
            catch (Exception ex)
            {
                Logger.Error("SocketInitiator create error", ex);
                throw;
            }
        }
Beispiel #35
0
  static void Main(string[] args)
  {
    string file = "";

    if( args.Length >= 2 && args[0].Equals("-f") && args[1] != null ) 
    {
      file = args[1];
	  }
    else 
    {
      Console.WriteLine( "usage: at" + " -f FILE [-t]" );
      return;
	  }

    SessionSettings settings = new SessionSettings(file);
    at_application application = new at_application();
    FileStoreFactory factory = new FileStoreFactory(settings);
    Acceptor acceptor = new SocketAcceptor
        ( application, factory, settings, new DefaultMessageFactory() );
    acceptor.start();
    while( true ) Thread.Sleep( 1000 );
  }
        public AbstractInitiator(SessionFactory factory, SessionSettings settings)
        {
            settings_ = settings;

            HashSet<SessionID> definedSessions = settings.GetSessions();
            if (0 == definedSessions.Count)
                throw new ConfigError("No sessions defined");

            foreach (SessionID sessionID in definedSessions)
            {
                Dictionary dict = settings.Get(sessionID);
                if ("initiator".Equals(dict.GetString(SessionSettings.CONNECTION_TYPE)))
                {
                    sessionIDs_.Add(sessionID);
                    sessions_[sessionID] = factory.Create(sessionID, dict);
                    SetDisconnected(sessionID);
                }
            }

            if (0 == sessions_.Count)
                throw new ConfigError("No sessions defined for initiator");
        }
Beispiel #37
0
        public FixApplication(String configFile)
        {
            try
            {
                logonCount = 0;
                Current = this;
                settings = new SessionSettings(configFile);
                storeFactory = new FileStoreFactory(settings);
                logFactory = new FileLogFactory(settings);
                messageFactory = new DefaultMessageFactory();
                SetSessionIndexes(configFile);

                initiator = new SocketInitiator(this, storeFactory, settings, logFactory, messageFactory);
                initiator.start();
                AddText("Created initiator." + Environment.NewLine);
            }
            catch (Exception exception)
            {
                AddText(exception.Message + Environment.NewLine);
                throw;
            }
        }
Beispiel #38
0
        public FileStore(SessionID sessionID, SessionSettings settings)
        {
            string path = settings.Get(sessionID).GetString(SessionSettings.FILE_STORE_PATH);

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            string prefix = Prefix(sessionID);

            seqNumsFileName_ = System.IO.Path.Combine(path, prefix + ".seqnums");
            msgFileName_     = System.IO.Path.Combine(path, prefix + ".body");
            headerFileName_  = System.IO.Path.Combine(path, prefix + ".header");
            sessionFileName_ = System.IO.Path.Combine(path, prefix + ".session");

            encoding_ = settings.Get(sessionID).Has(SessionSettings.ENCODING)
                ? Encoding.GetEncoding(settings.Get(sessionID).GetString(SessionSettings.ENCODING))
                : SessionFactory.DefaultEncoding;

            open();
        }
Beispiel #39
0
        static void Main(string[] args)
        {
            try
            {

                QuickFix.SessionSettings settings = new QuickFix.SessionSettings("config/quickfix-client.cfg");
                MyQuickFixApp application = new MyQuickFixApp();
                QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                QuickFix.ILogFactory logFactory = new QuickFix.ScreenLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);
                initiator.Start();
                Console.ReadKey();
                initiator.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Console.ReadKey();
            }
            Environment.Exit(1);
        }
Beispiel #40
0
        static void Main(string[] args)
        {
            Console.WriteLine("== CharEncoding Initiator startup");

            try
            {
                SessionSettings settings = new QuickFix.SessionSettings("initiator.cfg");
                CEInitiatorApp application = new CEInitiatorApp();
                IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                ILogFactory logFactory = new QuickFix.ScreenLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);

                initiator.Start();
                application.ListenOnConsole();
                initiator.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            Environment.Exit(1);
        }
Beispiel #41
0
        static void Main(string[] args)
        {
            Console.WriteLine("=== CharEncoding Acceptor startup");

            try
            {
                SessionSettings settings = new SessionSettings("acceptor.cfg");
                IApplication app = new CEAcceptorApp();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory logFactory = new FileLogFactory(settings);
                ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #42
0
        static void Main(string[] args)
        {
            string file = "client.cfg";

            try {
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings(file);
                Client application = new Client();
                QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                //QuickFix.ILogFactory logFactory = new QuickFix.ScreenLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings);

                // this is a developer-test kludge.  do not emulate.
                application.MyInitiator = initiator;

                initiator.Start();
                application.Run();
                initiator.Stop();
            } catch (System.Exception e) {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            Environment.Exit(1);
        }
        private void connectButton_Click(object sender, EventArgs e)
        {
            string file = "c:/FIX/tradeclientIB.cfg";

            try
            {
                QuickFix.SessionSettings      settings     = new QuickFix.SessionSettings(file);
                QuickFix.IApplication         myApp        = new MyQuickFixApp();
                QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                QuickFix.ILogFactory          logFactory   = new QuickFix.ScreenLogFactory(settings);
                //QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(myApp, storeFactory, settings, logFactory);
                _Initiator = new QuickFix.Transport.SocketInitiator(myApp, storeFactory, settings, logFactory);

                MyQuickFixApp.UpdateEvent += new MyQuickFixApp.OnUpdateEvent(AddLogItem);
                _Initiator.Start();
            }
            catch (System.Exception err)
            {
                Console.WriteLine(err.Message);
                Console.WriteLine(err.StackTrace);
                MessageBox.Show(err.ToString());
            }
        }
Beispiel #44
0
        static void Main(string[] args)
        {
            string file = "client.cfg";

            try {
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings(file);
                Client application = new Client();
                QuickFix.IMessageStoreFactory storeFactory = new QuickFix.FileStoreFactory(settings);
                //QuickFix.ILogFactory logFactory = new QuickFix.ScreenLogFactory(settings);
                QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings);

                // this is a developer-test kludge.  do not emulate.
                application.MyInitiator = initiator;

                initiator.Start();
                application.Run();
                initiator.Stop();
            } catch (System.Exception e) {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            Environment.Exit(1);
        }
Beispiel #45
0
        internal static void GetAccountInfo(SessionSettings ss)
        {
            foreach (var session in ss.getSessions())
            {
                var dict = ss.get(session as SessionID);

                target = dict.getString("TargetCompID");
                var dst = dict.getString("TargetCompID")
                    + " : " + dict.getString("SocketConnectHost")
                    + " : " + dict.getString("SocketConnectPort");
                Fix.Out(dst);

                var acc = dict.getString("Account");
                var cid = dict.getString("ClientID");

                if (!string.IsNullOrEmpty(acc) && !string.IsNullOrEmpty(cid))
                {
                    account = acc;
                    clientid = cid;
                }

                Fix.Out(Account.account + " / " + Account.clientid + "\n");
            }
        }
Beispiel #46
0
        static void Main(string[] args)
        {
            String configFile = "SchneiderBen.cfg";

            try
            {
                SessionSettings settings = new SessionSettings(configFile);
                FixApplication application = new FixApplication();
                FileStoreFactory storeFactory = new FileStoreFactory(settings);
                ScreenLogFactory logFactory = new ScreenLogFactory(settings);
                MessageFactory messageFactory = new DefaultMessageFactory();
                SocketInitiator initiator = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory);

                initiator.start();

                Console.WriteLine("press <enter> to quit");
                Console.Read();
                initiator.stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #47
0
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("This is only an example program.");
            Console.WriteLine("It's a simple server (e.g. Acceptor) app that will let clients (e.g. Initiators)");
            Console.WriteLine("connect to it.  It will accept and display any application-level messages that it receives.");
            Console.WriteLine("Connecting clients should set TargetCompID to 'SIMPLE' and SenderCompID to 'CLIENT1' or 'CLIENT2'.");
            Console.WriteLine("Port is 5001.");
            Console.WriteLine("(see simpleacc.cfg for configuration details)");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                Console.WriteLine("usage: SimpleAcceptor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings settings = new SessionSettings(args[0]);
                Application app = new SimpleAcceptorApp();
                MessageStoreFactory storeFactory = new FileStoreFactory(settings);
                LogFactory logFactory = new FileLogFactory(settings);
                IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory);

                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #48
0
        public FixServerInitiator(
            string channelsID,
            TCPReplayConfig tcpReplayConfig,
            Dictionary <string, SessionID> dctSessionsFixClients,
            Dictionary <string, SessionID> dctSessionsFixChannels)
        {
            _tcpReplayConfig        = tcpReplayConfig;
            _dctSessionsFixClients  = dctSessionsFixClients;
            _dctSessionsFixChannels = dctSessionsFixChannels;

            logger = LogManager.GetLogger("FixServerInitiator-" + tcpReplayConfig.ChannelID);

            MDSUtils.AddAppender("FixServerInitiator-" + tcpReplayConfig.ChannelID, logger.Logger);

            XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader();

            registry = UmdfUtils.loadTemplates(tcpReplayConfig.TemplateFile);
            context  = new Context();
            context.TemplateRegistry = registry;

            try
            {
                // Cria dicionario da configuracao
                QuickFix.Dictionary mainDic = new QuickFix.Dictionary();
                mainDic.SetString("SocketConnectHost", tcpReplayConfig.SocketConnectHost);
                mainDic.SetLong("SocketConnectPort", tcpReplayConfig.SocketConnectPort);
                if (!String.IsNullOrEmpty(tcpReplayConfig.SocketConnectHost1))
                {
                    mainDic.SetString("SocketConnectHost1", tcpReplayConfig.SocketConnectHost1);
                    mainDic.SetLong("SocketConnectPort1", tcpReplayConfig.SocketConnectPort1);
                }
                mainDic.SetLong("HeartBtInt", tcpReplayConfig.HeartBtInt);
                mainDic.SetLong("ReconnectInterval", tcpReplayConfig.ReconnectInterval);
                mainDic.SetBool("ResetOnLogon", tcpReplayConfig.ResetOnLogon);
                mainDic.SetBool("PersistMessages", tcpReplayConfig.PersistMessages);
                mainDic.SetString("ConnectionType", tcpReplayConfig.ConnectionType);
                mainDic.SetString("FileStorePath", tcpReplayConfig.FileStorePath);
                mainDic.SetString("FileLogPath", tcpReplayConfig.FileLogPath);
                mainDic.SetString("StartTime", tcpReplayConfig.StartTime);
                mainDic.SetString("EndTime", tcpReplayConfig.EndTime);

                QuickFix.Dictionary sessDic = new QuickFix.Dictionary();
                sessDic.SetString("BeginString", tcpReplayConfig.BeginString);
                sessDic.SetString("SenderCompID", tcpReplayConfig.SenderCompID);
                sessDic.SetString("TargetCompID", tcpReplayConfig.TargetCompID);
                sessDic.SetString("DataDictionary", tcpReplayConfig.DataDictionary);
                sessDic.SetBool("UseDataDictionary", true);

                // Configure the session settings
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

                settings.Set(mainDic);

                MemoryStoreFactory store   = new MemoryStoreFactory();
                FileLogFactory     log     = new FileLogFactory(settings);
                IMessageFactory    message = new DefaultMessageFactory();

                // Cria sessao FIX
                _sessionID = new QuickFix.SessionID(
                    tcpReplayConfig.BeginString,
                    tcpReplayConfig.SenderCompID,
                    tcpReplayConfig.TargetCompID);

                settings.Set(_sessionID, sessDic);

                string[] quebraChannelsID = channelsID.Split(",".ToCharArray());
                foreach (string channel in quebraChannelsID)
                {
                    dctSessionsFixChannels.Add(channel, _sessionID);
                }

                logger.InfoFormat("Start(): iniciando FIX com sessionID[{0}]...", _sessionID.ToString());
                _initiator = new QuickFix.Transport.SocketInitiator(this, store, settings, log, message);
                _initiator.Start();
            }
            catch (Exception ex)
            {
                logger.Error("Start():" + ex.Message, ex);
            }

            logger.Info("Start(): Sessao FIX iniciada!");
        }
Beispiel #49
0
        public FixInitiator(MarketIncrementalProcessor mktIncProc, ChannelUMDFConfig channelUmdfConfig, string templateFile, Queue <UdpPacket> qUdpPkt, Object replayLockObject)
        {
            logger = LogManager.GetLogger("FixInitiator-" + channelUmdfConfig.ChannelID);

            MDSUtils.AddAppender("FixInitiator-" + channelUmdfConfig.ChannelID, logger.Logger);

            XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader();

            registry = UmdfUtils.loadTemplates(templateFile);
            context  = new Context();
            context.TemplateRegistry = registry;

            _mktIncProc        = mktIncProc;
            _channelUmdfConfig = channelUmdfConfig;

            if (!listaChannelQueues.ContainsKey(channelUmdfConfig.ChannelID))
            {
                listaChannelQueues.Add(channelUmdfConfig.ChannelID, new ListChannelQueues(qUdpPkt, replayLockObject));
            }

            logger.Info("Start(): iniciando sessao FIX...");
            try
            {
                // Cria sessao FIX
                _session = new QuickFix.SessionID(
                    _channelUmdfConfig.TCPConfig.BeginString,
                    _channelUmdfConfig.TCPReplayConfig.SenderCompID,
                    _channelUmdfConfig.TCPReplayConfig.SubID,
                    _channelUmdfConfig.TCPReplayConfig.TargetCompID,
                    _channelUmdfConfig.TCPReplayConfig.SubID);

                // Cria dicionario da configuracao
                QuickFix.Dictionary mainDic = new QuickFix.Dictionary();
                mainDic.SetLong("SocketConnectPort", _channelUmdfConfig.TCPReplayConfig.SocketConnectPort);
                mainDic.SetLong("HeartBtInt", _channelUmdfConfig.TCPConfig.HeartBtInt);
                mainDic.SetLong("ReconnectInterval", _channelUmdfConfig.TCPConfig.ReconnectInterval);
                mainDic.SetBool("ResetOnLogon", _channelUmdfConfig.TCPConfig.ResetOnLogon);
                mainDic.SetBool("ResetOnLogout", _channelUmdfConfig.TCPConfig.ResetOnLogout);
                mainDic.SetBool("ResetOnDisconnect", _channelUmdfConfig.TCPConfig.ResetOnDisconnect);
                mainDic.SetBool("PersistMessages", _channelUmdfConfig.TCPConfig.PersistMessages);
                mainDic.SetString("ConnectionType", _channelUmdfConfig.TCPConfig.ConnectionType);
                mainDic.SetString("SocketConnectHost", _channelUmdfConfig.TCPReplayConfig.SocketConnectHost);
                mainDic.SetString("FileStorePath", _channelUmdfConfig.TCPConfig.FileStorePath);
                mainDic.SetString("FileLogPath", _channelUmdfConfig.TCPConfig.FileLogPath);
                mainDic.SetString("StartTime", _channelUmdfConfig.TCPReplayConfig.StartTime);
                mainDic.SetString("EndTime", _channelUmdfConfig.TCPReplayConfig.EndTime);

                QuickFix.Dictionary sessDic = new QuickFix.Dictionary();
                sessDic.SetString("BeginString", _channelUmdfConfig.TCPConfig.BeginString);
                sessDic.SetString("SenderCompID", _channelUmdfConfig.TCPReplayConfig.SenderCompID);
                sessDic.SetString("SenderSubID", _channelUmdfConfig.TCPReplayConfig.SubID);
                sessDic.SetString("TargetCompID", _channelUmdfConfig.TCPReplayConfig.TargetCompID);
                sessDic.SetString("TargetSubID", _channelUmdfConfig.TCPReplayConfig.SubID);
                sessDic.SetString("DataDictionary", _channelUmdfConfig.TCPConfig.DataDictionary);
                sessDic.SetBool("UseDataDictionary", true);

                // Configure the session settings
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

                settings.Set(mainDic);
                settings.Set(_session, sessDic);

                MemoryStoreFactory store   = new MemoryStoreFactory();
                FileLogFactory     log     = new FileLogFactory(settings);
                IMessageFactory    message = new DefaultMessageFactory();

                // Cria o socket
                _initiator = new QuickFix.Transport.SocketInitiator(this, store, settings, log, message);
                _initiator.Start();
            }
            catch (Exception ex)
            {
                logger.Error("Start():" + ex.Message, ex);
            }

            logger.Info("Start(): Sessao FIX iniciado!");
        }
Beispiel #50
0
        public FixServerAcceptor(
            TCPReplayConfig tcpReplayConfig,
            Dictionary <string, SessionID> dctSessionsFixClients,
            Dictionary <string, SessionID> dctSessionsFixChannels)
        {
            _tcpReplayConfig        = tcpReplayConfig;
            _dctSessionsFixClients  = dctSessionsFixClients;
            _dctSessionsFixChannels = dctSessionsFixChannels;

            logger = LogManager.GetLogger("FixServerAcceptor");

            MDSUtils.AddAppender("FixServerAcceptor", logger.Logger);

            XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader();

            registry = UmdfUtils.loadTemplates(tcpReplayConfig.TemplateFile);
            context  = new Context();
            context.TemplateRegistry = registry;

            try
            {
                // Cria dicionario da configuracao
                QuickFix.Dictionary mainDic = new QuickFix.Dictionary();
                mainDic.SetLong("SocketAcceptPort", tcpReplayConfig.SocketAcceptPort);
                mainDic.SetBool("ResetOnLogon", tcpReplayConfig.ResetOnLogon);
                mainDic.SetBool("ResetOnDisconnect", tcpReplayConfig.ResetOnDisconnect);
                mainDic.SetBool("PersistMessages", tcpReplayConfig.PersistMessages);
                mainDic.SetString("ConnectionType", tcpReplayConfig.ConnectionType);
                mainDic.SetString("FileStorePath", tcpReplayConfig.FileStorePath);
                mainDic.SetString("FileLogPath", tcpReplayConfig.FileLogPath);
                mainDic.SetString("StartTime", tcpReplayConfig.StartTime);
                mainDic.SetString("EndTime", tcpReplayConfig.EndTime);

                QuickFix.Dictionary sessDic = new QuickFix.Dictionary();
                sessDic.SetString("BeginString", tcpReplayConfig.BeginString);
                sessDic.SetString("SenderCompID", tcpReplayConfig.SenderCompID);
                sessDic.SetString("TargetCompID", tcpReplayConfig.TargetCompID);
                sessDic.SetString("DataDictionary", tcpReplayConfig.DataDictionary);
                sessDic.SetBool("UseDataDictionary", true);

                // Configure the session settings
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

                settings.Set(mainDic);

                MemoryStoreFactory store   = new MemoryStoreFactory();
                FileLogFactory     log     = new FileLogFactory(settings);
                IMessageFactory    message = new DefaultMessageFactory();

                IEnumerable <int> rangeSenderSubID = Enumerable.Range(
                    tcpReplayConfig.SubIDStartSeq,
                    tcpReplayConfig.SubIDEndSeq);
                foreach (int item in rangeSenderSubID)
                {
                    string subID = tcpReplayConfig.SubIDPrefix + item.ToString("D3");

                    // Cria sessao FIX
                    SessionID sessionID = new QuickFix.SessionID(
                        tcpReplayConfig.BeginString,
                        tcpReplayConfig.SenderCompID,
                        subID,
                        tcpReplayConfig.TargetCompID,
                        subID);

                    sessDic.SetString("SenderSubID", subID);
                    sessDic.SetString("TargetSubID", subID);
                    settings.Set(sessionID, sessDic);
                }

                logger.InfoFormat("Start(): iniciando FIX ACCEPTOR na porta {0}...", tcpReplayConfig.SocketAcceptPort);
                _acceptor = new ThreadedSocketAcceptor(this, store, settings, log, message);
                _acceptor.Start();
            }
            catch (Exception ex)
            {
                logger.Error("Start():" + ex.Message, ex);
            }

            logger.Info("Start(): Sessao FIX iniciada!");
        }
 public ThreadedSocketAcceptor(IApplication application, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
     : this(new SessionFactory(application, storeFactory, logFactory, messageFactory), settings)
 {
 }
 public AbstractInitiator(Application application, MessageStoreFactory storeFactory, SessionSettings settings)
     : this(application, storeFactory, settings, null)
 {
 }
Beispiel #53
0
 private void Init()
 {
     try
     {
         this._settings = new QuickFix.SessionSettings(settingfile);
         this._messageStoreFactory = new QuickFix.FileStoreFactory(this._settings);
         this._logFactory = new QuickFix.FileLogFactory(this._settings);
         this._messageFactory = new QuickFix42.MessageFactory();
         this._socketInitiator = new QuickFix.SocketInitiator  (this, _messageStoreFactory, this._settings, this._logFactory, _messageFactory);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Beispiel #54
0
 public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory)
     : this(app, storeFactory, settings, logFactory, null)
 {
 }
Beispiel #55
0
 /// <summary>
 /// Create a ThreadedSocketAcceptor with a DefaultMessageFactory
 /// </summary>
 /// <param name="application"></param>
 /// <param name="storeFactory"></param>
 /// <param name="settings"></param>
 /// <param name="logFactory"></param>
 public ThreadedSocketAcceptor(IApplication application, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory)
     : this(application, storeFactory, settings, logFactory, null)
 {
 }
Beispiel #56
0
 protected virtual void OnInitialize(SessionSettings settings)
 {
 }
Beispiel #57
0
 /// <summary>
 /// Override this to configure additional implemenation-specific settings
 /// </summary>
 /// <param name="settings"></param>
 protected virtual void OnConfigure(SessionSettings settings)
 {
 }
 public AbstractInitiator(Application app, MessageStoreFactory storeFactory, SessionSettings settings, LogFactory logFactory)
     : this(app, storeFactory, settings, logFactory, null)
 {
 }
 /// <summary>
 /// Implemented to initialize initiator
 /// </summary>
 /// <param name="settings"></param>
 protected virtual void OnInitialize(SessionSettings settings)
 {
 }
 /// <summary>
 /// Implemented to configure acceptor
 /// </summary>
 /// <param name="settings"></param>
 protected virtual void OnConfigure(SessionSettings settings)
 {
 }