コード例 #1
0
        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName));
            var mode = args.FirstOrDefault();

            Serilog.Log.Logger = new LoggerConfiguration()
                                 .Enrich.FromLogContext()
                                 .WriteTo.Console()
                                 .WriteTo.File($"logs/{mode}-.log", rollingInterval: RollingInterval.Day)
                                 .CreateLogger();

            IInitiator initiator = null;
            IAcceptor  acceptor  = null;

            if (mode == "client")
            {
                var clientSettings = new SessionSettings("client.cfg");
                initiator = new SocketInitiator(new ClientApp(100_000), new MemoryStoreFactory(), clientSettings, new FileLogFactory(clientSettings), new MessageFactory());
                initiator.Start();
            }
            else
            {
                var serverSettings = new SessionSettings("server.cfg");
                acceptor = new ThreadedSocketAcceptor(new ServerApp(), new MemoryStoreFactory(), serverSettings, new FileLogFactory(serverSettings), new MessageFactory());
                acceptor.Start();
            }

            Console.ReadLine();
            Console.WriteLine("Bye");

            initiator?.Stop(true);
            acceptor?.Stop(true);
        }
コード例 #2
0
ファイル: ATRunner.cs プロジェクト: ckiaraM/quickfixn
        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"));

            try
            {
                SessionSettings     settings     = new SessionSettings(args[0]);
                Application         testApp      = new ATApplication(debugLog);
                MessageStoreFactory storeFactory = new FileStoreFactory(settings);
                LogFactory          logFactory   = null;
                if (settings.Get().Has("Verbose") && settings.Get().GetBool("Verbose"))
                {
                    logFactory = new FileLogFactory(settings); //ScreenLogFactory(true, true, true);
                }
                ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(testApp, storeFactory, settings, logFactory);

                acceptor.Start();
                while (true)
                {
                    System.Console.WriteLine("o hai");
                    System.Threading.Thread.Sleep(1000);
                }
                //acceptor.Stop();
            }
            catch (System.Exception e)
            {
                debugLog.OnEvent(e.ToString());
            }
        }
コード例 #3
0
        void StartEngine(bool initiator)
        {
            TestApplication      application  = new TestApplication(LogonCallback, LogoffCallback);
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            SessionSettings      settings     = new SessionSettings();
            Dictionary           defaults     = new Dictionary();

            defaults.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, _logPath);

            // Put IP endpoint settings into default section to verify that that defaults get merged into
            // session-specific settings not only for static sessions, but also for dynamic ones
            defaults.SetString(SessionSettings.SOCKET_CONNECT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_CONNECT_PORT, ConnectPort.ToString());
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_PORT, AcceptPort.ToString());

            settings.Set(defaults);
            ILogFactory logFactory = new FileLogFactory(settings);

            if (initiator)
            {
                defaults.SetString(SessionSettings.RECONNECT_INTERVAL, "1");
                settings.Set(CreateSessionID(StaticInitiatorCompID), CreateSessionConfig(StaticInitiatorCompID, true));
                _initiator = new SocketInitiator(application, storeFactory, settings, logFactory);
                _initiator.Start();
            }
            else
            {
                settings.Set(CreateSessionID(StaticAcceptorCompID), CreateSessionConfig(StaticAcceptorCompID, false));
                _acceptor = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);
                _acceptor.Start();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: ckiaraM/quickfixn
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("usage: Executor CONFIG_FILENAME");
                System.Environment.Exit(2);
            }

            try
            {
                SessionSettings        settings     = new SessionSettings(args[0]);
                Application            executorApp  = new Executor();
                MessageStoreFactory    storeFactory = new FileStoreFactory(settings);
                LogFactory             logFactory   = new ScreenLogFactory(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: " + e.Message);
                Console.WriteLine(e.ToString());
            }
        }
コード例 #5
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Iniciando.....");
                SessionSettings        settings     = new SessionSettings("../../../executor.cfg");
                IApplication           myApp        = new MyQuickFixApp();
                IMessageStoreFactory   storeFactory = new FileStoreFactory(settings);
                ILogFactory            logFactory   = new FileLogFactory(settings);
                ThreadedSocketAcceptor acceptor     = new ThreadedSocketAcceptor(
                    myApp,
                    storeFactory,
                    settings,
                    logFactory);
                HttpServer srv = new HttpServer(HttpServerPrefix, settings);

                //Iniciando acceptor
                acceptor.Start();
                //Iniciando servidor http
                srv.Start();
                Console.WriteLine("Rodando em: " + HttpServerPrefix);
                Console.WriteLine("Aperte enter para finalizar");
                Console.ReadLine();
                //Finalizando acceptor e servidor http
                srv.Stop();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Error");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: fxmozart/quickfixn-1
        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());
            }
        }
コード例 #7
0
        static void Main(string[] args)
        {
            var configBroker = AppDomain.CurrentDomain.BaseDirectory + "\\sample_acceptor.cfg";

            SessionSettings settings = new SessionSettings(configBroker);

            IMessageStoreFactory storeFactory = new FileStoreFactory(settings);

            ILogFactory logFactory = new FileLogFactory(settings);

            var broker = new TradeAcceptor();

            ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(
                broker,
                storeFactory,
                settings,
                logFactory);

            string HttpServerPrefix = "http://127.0.0.1:5080/";

            HttpServer srv = new HttpServer(HttpServerPrefix, settings);

            acceptor.Start();

            srv.Start();

            Console.WriteLine("View Executor status: " + HttpServerPrefix);

            Run();

            srv.Stop();

            acceptor.Stop();
        }
コード例 #8
0
ファイル: ATRunner.cs プロジェクト: janvanderhaegen/quickfixn
        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(), Severity.Error, e);
            }

            finally
            {
                if (acceptor != null)
                {
                    acceptor.Stop();
                }
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: IressSmartHub/quickfixn
        static void Main(string[] args)
        {
            SessionSettings        settings     = new SessionSettings("ini.cfg");
            IApplication           fixHub       = new FixHub();
            IMessageStoreFactory   storeFactory = new FileStoreFactory(settings);
            ILogFactory            logFactory   = new FileLogFactory(settings);
            ThreadedSocketAcceptor acceptor     = new ThreadedSocketAcceptor(fixHub, storeFactory, settings, logFactory);

            acceptor.Start();
            Console.ReadKey();
            acceptor.Stop();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: Jason6583/TradingUIDemo
        static void Main(string[] args)
        {
            SessionID _DummySessionID = new SessionID("a", "b", "c");

            IMessageFactory _defaultMsgFactory = new DefaultMessageFactory();

            //string data = "8=FIXT.1.1"+Message.SOH+"9=735"+Message.SOH+"35=AE"+Message.SOH+"34=494"+Message.SOH+"1128=8"+Message.SOH+"49=RTNSFIXUAT"+Message.SOH+"56=YEPIRECUAT"+Message.SOH+"52=20151027-11:59:15"+Message.SOH+"552=1"+Message.SOH+"54=1"+Message.SOH+"37=Z0009WSGC4"+Message.SOH+"11=NOREF"+Message.SOH+"826=0"+Message.SOH+"78=1"+Message.SOH+"79=NOT SPECIFIED"+Message.SOH+"80=120.000000"+Message.SOH+"5967=91.070000"+Message.SOH+"5966=120.000000"+Message.SOH+"5968=91.040000"+Message.SOH+"453=5"+Message.SOH+"448=YPKB"+Message.SOH+"452=3"+Message.SOH+"447=D"+Message.SOH+"802=1"+Message.SOH+"523=YPKB"+Message.SOH+"803=5"+Message.SOH+"448=BARX"+Message.SOH+"452=1"+Message.SOH+"447=D"+Message.SOH+"802=1"+Message.SOH+"523=BARX"+Message.SOH+"803=5"+Message.SOH+"448=BARX"+Message.SOH+"452=16"+Message.SOH+"447=D"+Message.SOH+"802=1"+Message.SOH+"523=BARX"+Message.SOH+"803=5"+Message.SOH+"448=bcart7"+Message.SOH+"452=11"+Message.SOH+"447=D"+Message.SOH+"448=Barclays Capital"+Message.SOH+"452=12"+Message.SOH+"447=D"+Message.SOH+"571=10106232"+Message.SOH+"150=F"+Message.SOH+"17=Z0009WSGC4"+Message.SOH+"32=120.000000"+Message.SOH+"38=120.000000"+Message.SOH+"15=CAD"+Message.SOH+"31=1.317700"+Message.SOH+"555=2"+Message.SOH+"624=1"+Message.SOH+"637=1.317700"+Message.SOH+"1418=120.000000"+Message.SOH+"588=20151028"+Message.SOH+"587=0"+Message.SOH+"1073=0.0000"+Message.SOH+"1074=91.070000"+Message.SOH+"5190=1.317700"+Message.SOH+"624=2"+Message.SOH+"637=1.318062"+Message.SOH+"1418=120.000000"+Message.SOH+"588=20151130"+Message.SOH+"587=M1"+Message.SOH+"1073=3.6200"+Message.SOH+"1074=91.040000"+Message.SOH+"5190=1.317700"+Message.SOH+"60=20151027-11:59:14"+Message.SOH+"75=20151027"+Message.SOH+"1057=Y"+Message.SOH+"39=2"+Message.SOH+"460=4"+Message.SOH+"167=FOR"+Message.SOH+"65=SW"+Message.SOH+"55=USD/CAD"+Message.SOH+"10=076"+Message.SOH;

            //var msg = new QuickFix.FIX50.TradeCaptureReport();
            //var dd = new QuickFix.DataDictionary.DataDictionary();
            //dd.Load(@"C:\Code\tfs\neerajkaushik\MarketConnect Gateway\Source\Source\QuickFix1.5\quickfixn-master\quickfixn-master\spec\fix\reuters.fix50sp1.xml");
            //msg.FromString(data, false, dd, dd, _defaultMsgFactory);

            //MessageCracker mc = new TestCracker();

            //mc.Crack(msg, _DummySessionID);

            //var grp = msg.GetGroup(1, Tags.NoLegs);



            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("=============");



            try
            {
                SessionSettings        settings     = new SessionSettings("acceptor.cfg");
                Application            executorApp  = new Executor();
                MessageStoreFactory    storeFactory = new FileStoreFactory(settings);
                LogFactory             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());
                Console.WriteLine("press <enter> to quit");
                Console.Read();
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: akamyshanov/quickfixn-tmp
        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();
        }
コード例 #12
0
ファイル: FixDropCopy.cs プロジェクト: radtek/Gradual
        public void Stop()
        {
            try
            {
                logger.Info("Finalizando ThreadedSocketAcceptor - Sessao DropCopy");

                _running             = false;
                _finalizarSinalizado = true;
                try
                {
                    if (_socketDropCopy != null)
                    {
                        _socketDropCopy.Stop();
                        _socketDropCopy = null;
                    }

                    logger.Info("Stop(): Finalizando Thread thDropCopy");
                    if (_thDropCopy.IsAlive)
                    {
                        _thDropCopy.Abort();
                        _thDropCopy = null;
                    }

                    foreach (KeyValuePair <int, List <SessionDropCopy> > pair in _dicSessionsDropCopy)
                    {
                        int len = pair.Value.Count;
                        for (int i = 0; i < len; i++)
                        {
                            pair.Value[i].Stop();
                            pair.Value[i].Config = null;
                        }
                    }
                    _dicSessionsDropCopy.Clear();
                    _dicSessionsDropCopy = null;
                }
                catch (Exception ex)
                {
                    logger.Error("Erro em Finalizar SocketAcceptor():" + ex.Message, ex);
                }
                finally
                {
                }
                logger.Info("*** SocketAcceptor finalizado ***");
            }
            catch (Exception ex)
            {
                logger.Error("Problemas no stop da sessao FixDropCopy: " + ex.Message, ex);
            }
        }
コード例 #13
0
 public OrderMatchingEngine(
     IApplication requestNetworkHandler,
     SessionSettings sessionSettings,
     FileStoreFactory fileStoreFactory,
     FileLogFactory fileLogFactory)
 {
     this.requestNetworkHandler = requestNetworkHandler;
     this.sessionSettings       = sessionSettings;
     this.fileStoreFactory      = fileStoreFactory;
     this.fileLogFactory        = fileLogFactory;
     this.acceptor = new ThreadedSocketAcceptor(requestNetworkHandler,
                                                fileStoreFactory,
                                                sessionSettings,
                                                fileLogFactory);
 }
コード例 #14
0
        static void Main(string[] args)
        {
            SessionSettings settings = new SessionSettings(@"C:\acceptor.cfg");
            Startup application = new Startup();

            FileStoreFactory storeFactory = new FileStoreFactory(settings);
            ScreenLogFactory logFactory = new ScreenLogFactory(settings);
            IMessageFactory messageFactory = new DefaultMessageFactory();
            ThreadedSocketAcceptor server = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory, messageFactory);

            server.Start();
            Console.WriteLine("####### Server Socket Fix Start ...press <enter> to quit");

            Console.Read();
            server.Stop();
        }
コード例 #15
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);
            }
        }
コード例 #16
0
        public void TearDown()
        {
            if (_listenSocket != null)
            {
                _listenSocket.Close();
            }
            if (_initiator != null)
            {
                _initiator.Stop(true);
            }
            if (_acceptor != null)
            {
                _acceptor.Stop(true);
            }

            _initiator = null;
            _acceptor  = null;
        }
コード例 #17
0
        public void TearDown()
        {
            if (_listenSocket != null)
            {
                _listenSocket.Close();
            }
            if (_initiator != null)
            {
                _initiator.Stop(true);
            }
            if (_acceptor != null)
            {
                _acceptor.Stop(true);
            }

            _initiator = null;
            _acceptor  = null;

            Thread.Sleep(500);
            ClearLogs();
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: Clanrat/FIXAcceptor
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration().WriteTo.File("serilogfile.txt").WriteTo.Console().Enrich.FromLogContext().CreateLogger();

            var doc = new XmlDocument();

            doc.Load("C:/FixGenium.xml");


            var settings     = new SessionSettings("fixconfig.ini");
            var application  = new EmptyQuickfixApp();
            var storeFactory = new MemoryStoreFactory();
            var logFactory   = new FileLogFactory(settings);
            var acceptor     = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);

            acceptor.Start();


            Console.WriteLine("Started");

            Console.ReadLine();
        }
コード例 #19
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");
            }

            try
            {
                var configPath = "..\\Debug\\sample_acceptor.cfg";

                SessionSettings      settings     = new SessionSettings(configPath);
                IApplication         app          = new SimpleAcceptorApp();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory          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());
            }
        }
コード例 #20
0
ファイル: FixServerAcceptor.cs プロジェクト: radtek/Gradual
        public void Stop()
        {
            try
            {
                _acceptor.Stop();
                _acceptor = null;

                Dictionary <string, SessionID> .Enumerator itens = _dctSessionsFixClients.GetEnumerator();
                while (itens.MoveNext())
                {
                    KeyValuePair <string, SessionID> item = itens.Current;
                    SessionID session = item.Value;
                    session = null;
                }
                _dctSessionsFixClients.Clear();
            }
            catch (Exception ex)
            {
                logger.Error("Stop():" + ex.Message, ex);
            }

            logger.Info("Stop(): Sessao FIX finalizado!");
        }
コード例 #21
0
        void StartEngine(bool initiator)
        {
            TestApplication      application  = new TestApplication(LogonCallback, LogoffCallback);
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            ILogFactory          logFactory   = new ScreenLogFactory(false, false, false);
            SessionSettings      settings     = new SessionSettings();

            if (initiator)
            {
                Dictionary defaults = new Dictionary();
                defaults.SetString(SessionSettings.RECONNECT_INTERVAL, "1");
                settings.Set(defaults);
                settings.Set(CreateSessionID(StaticInitiatorCompID), CreateSessionConfig(StaticInitiatorCompID, true));
                _initiator = new SocketInitiator(application, storeFactory, settings, logFactory);
                _initiator.Start();
            }
            else
            {
                settings.Set(CreateSessionID(StaticAcceptorCompID), CreateSessionConfig(StaticAcceptorCompID, false));
                _acceptor = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);
                _acceptor.Start();
            }
        }
コード例 #22
0
        public void initAcceptor(string file)
        {
            SessionSettings        settings     = new SessionSettings(file);
            IMessageStoreFactory   storeFactory = new FileStoreFactory(settings);
            ILogFactory            logFactory   = new FileLogFactory(settings);
            ThreadedSocketAcceptor acceptor     = new ThreadedSocketAcceptor(
                this,
                storeFactory,
                settings,
                logFactory
                );

            acceptor.Start();
            var i = 0;

            while (true)
            {
                Console.WriteLine("listening for {0} seconds...", i);
                System.Threading.Thread.Sleep(1000);
                ++i;
            }
            acceptor.Stop();
        }
コード例 #23
0
        private ThreadedSocketAcceptor createAcceptor(IApplication app, string encoding)
        {
            string accetorConfiguration = new StringBuilder()
                                          .AppendLine("[DEFAULT]")
                                          .AppendLine("ConnectionType=acceptor")
                                          .AppendLine("StartTime=00:00:00")
                                          .AppendLine("EndTime=00:00:00")
                                          .AppendLine("UseDataDictionary=N")
                                          .AppendLine("SocketAcceptHost=127.0.0.1")
                                          .AppendLine("SocketAcceptPort=10000")
                                          .AppendLine("HeartBtInt=30")

                                          .AppendLine("[SESSION]")
                                          .AppendLine("BeginString=FIX.4.2")
                                          .AppendLine("SenderCompID=Tom")
                                          .AppendLine("TargetCompID=Simor")
                                          .AppendLine(encoding != null ? "Encoding=" + encoding : "")
                                          .ToString();

            SessionSettings        settings = new SessionSettings(new System.IO.StringReader(accetorConfiguration));
            ThreadedSocketAcceptor tsa      = new ThreadedSocketAcceptor(app, new MemoryStoreFactory(), settings, null /* new ScreenLogFactory(true, true,true)*/);

            return(tsa);
        }
コード例 #24
0
        static void Main(string[] args)
        {
            Console.WriteLine("=============");
            Console.WriteLine("Executor, use with the TradeClient.");
            Console.WriteLine("=============");

            if (args.Length != 1)
            {
                Console.WriteLine("usage: Executor CONFIG_FILENAME");
                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);
                HttpServer             srv          = new HttpServer(HttpServerPrefix, settings);

                acceptor.Start();
                srv.Start();

                Console.WriteLine("View Executor status: " + HttpServerPrefix);
                //Console.Read();

                //srv.Stop();
                //acceptor.Stop();
            }
            catch (Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #25
0
ファイル: ServidorFix.cs プロジェクト: radtek/Gradual
        public void IniciarServico()
        {
            logger.Info("IniciarServico(): iniciando Servidor FIX...");

            // Carrega configurações
            _config = GerenciadorConfig.ReceberConfig <ServidorFixConfig>();

            // Cria dicionario da configuracao
            Dictionary mainDic = new Dictionary();

            if (_config.SocketAcceptPort > 0)
            {
                mainDic.SetLong("SocketAcceptPort", _config.SocketAcceptPort);
            }
            //mainDic.SetLong("SocketConnectPort", _config.SocketConnectPort);
            mainDic.SetLong("HeartBtInt", _config.HeartBtInt);
            mainDic.SetLong("ReconnectInterval", _config.ReconnectInterval);

            //mainDic.SetBool("ResetOnLogon", _config.ResetSeqNum);
            //mainDic.SetBool("PersistMessages", _config.PersistMessages);

            // Ver
            // ret.setString("ConnectionType", ConnectionType.ToLower());
            //mainDic.SetString("SocketConnectHost", _config.Host);
            mainDic.SetString("FileStorePath", _config.FileStorePath);

            logger.Debug("FileLogPath: " + _config.FileLogPath);
            mainDic.SetString("FileLogPath", _config.FileLogPath);

            logger.Debug("DebugFileLogPath: " + _config.FileLogPath);
            mainDic.SetString("DebugFileLogPath", _config.DebugFileLogPath);
            mainDic.SetString("StartTime", _config.StartTime);
            mainDic.SetString("EndTime", _config.EndTime);
            mainDic.SetString("ConnectionType", "acceptor");

            CamadaDeDados         db       = new CamadaDeDados();
            List <SessionFixInfo> sessions = db.BuscarSessoesFIX();

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

            settings.Set(mainDic);


            foreach (SessionFixInfo info in sessions)
            {
                Dictionary sessDic = new Dictionary();

                //sessDic.SetString("BeginString", _config.BeginString);
                //sessDic.SetString("SenderCompID", _config.SenderCompID);
                //sessDic.SetString("TargetCompID", _config.TargetCompID);

                string dataDictionary;

                switch (info.FixVersion)
                {
                case "5.0": dataDictionary = _config.DataDictionary50; break;

                case "4.4": dataDictionary = _config.DataDictionary44; break;

                case "4.2":
                default:
                    dataDictionary = _config.DataDictionary42; break;
                }

                sessDic.SetString("DataDictionary", dataDictionary);
                sessDic.SetBool("UseDataDictionary", true);
                sessDic.SetBool("ResetOnLogon", info.ResetSeqNum != 0?true:false);
                sessDic.SetBool("PersistMessages", info.PersistMessages != 0 ? true : false);

                logger.InfoFormat("Criando sessao S:[{0}] T:[{1}] Ver:[{2}] Dic:[{3}] Rst:[{4}] Pers:[{5}] Begstr:[{6}]",
                                  info.SenderCompID,
                                  info.TargetCompID,
                                  info.FixVersion,
                                  dataDictionary,
                                  info.ResetSeqNum,
                                  info.PersistMessages,
                                  info.BeginString
                                  );

                // Cria sessao que será usada para mandar as mensagens
                _session =
                    new SessionID(info.BeginString,
                                  info.SenderCompID,
                                  info.TargetCompID);

                settings.Set(_session, sessDic);
            }

            logger.Info("Iniciando gerenciador de limites...");
            LimiteManager.GetInstance().Start();

            logger.Info("Iniciando cron scheduler...");
            _cron = new CronStyleScheduler();
            _cron.Start();

            logger.Info("Iniciando Executor FIX...");
            _executorApp = Executor.GetInstance();
            _executorApp.Start();

            FileStoreFactory store = new FileStoreFactory(settings);

            LogFactory      logs = new FileLogFactory(settings);
            IMessageFactory msgs = new DefaultMessageFactory();

            logger.Info("Iniciando ThreadedSocketAcceptor...");
            _socketAcceptor = new ThreadedSocketAcceptor(_executorApp, store, settings, logs, msgs);
            _socketAcceptor.Start();

            _status = ServicoStatus.EmExecucao;

            logger.Info("IniciarServico(): ServidorFIX em execucao....");
        }
コード例 #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("============================================");
            Console.WriteLine("===== Hello proof of concept world. ========");
            Console.WriteLine("===== Simple acceptor (3)           ========");
            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("see also, revised and updated from the boilerplate doc...");
            Console.WriteLine("usage: SimpleAcceptor3 cfg/simpleAcceptorThree.cfg");
            Console.WriteLine("=============");

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

            try
            {
                // debug cwd
                var currentDirectory_one           = System.Environment.CurrentDirectory;
                var currentDirectory_BaseDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
                Console.WriteLine($"Current directory from system env: {currentDirectory_one}");
                Console.WriteLine($"Current directory from app domain base dir: {currentDirectory_BaseDirectory}");

                /*
                 * Current directory from system env: C:\Users\marc\source\repos\SimpleAcceptor3\SimpleAcceptor3
                 * So, quickfix is using the system.env.currentdirectory as its base folder when it navigates
                 * to the DataDictionary file from the relative file path defined in the .cfg config file.
                 * */

                SessionSettings      settings     = new SessionSettings(args[0]);
                IApplication         app          = new SimpleAcceptorThreeApp();
                IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
                ILogFactory          logFactory   = new FileLogFactory(settings);

                // dbg filepath to fix spec files
                Console.WriteLine("Spilling all session ids");
                var sessionsFromSettings = settings.GetSessions();
                foreach (var sess in sessionsFromSettings)
                {
                    Console.WriteLine($"(dbg) session: {sess.ToString()}");
                }
                var sessionId = "FIX.4.2:SIMPLE->CLIENT1";

                var sessionSettingsStringified = settings.ToString();
                Console.WriteLine($"Session settings spill: {sessionSettingsStringified}");

                // problems...
                // if filepath errors from settings to data dictionary file, this will fault.
                IAcceptor acceptor = new ThreadedSocketAcceptor(app, storeFactory, settings, logFactory);
                // possibly look at lower-level ways to construct gthe socker acceptor (or socker initiator) relying less on files, more programmatic.


                acceptor.Start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.Stop();
            }
            catch (System.Exception e)
            {
                Console.WriteLine("==FATAL ERROR==");
                Console.WriteLine(e.ToString());
            }
        }
コード例 #27
0
ファイル: Class1.cs プロジェクト: sw00/algo-poc
 public SimulatorTest()
 {
     _server = createAppFrom(@"Config\acceptor.cfg");
     _client = createAppFrom(@"Config\initiator.cfg");
 }
コード例 #28
0
ファイル: FixDropCopy.cs プロジェクト: radtek/Gradual
        public void Start()
        {
            try
            {
                logger.Info("FixDropCopy Start(): Iniciando ThreadedSocketAcceptor....");
                _running = true;

                // Buscar Application Path para compor diretorios de dicionario e afins(Substring(6) para retirar 'file:\')
                string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(FixAcceptor)).CodeBase).Substring(6);
                logger.Info("Application Path: " + path);
                _config = GerenciadorConfig.ReceberConfig <FixDropCopyConfig>();
                // Cria dicionario da configuracao
                Dictionary mainDic = new Dictionary();

                if (_config.SocketAcceptPort > 0)
                {
                    mainDic.SetLong("SocketAcceptPort", _config.SocketAcceptPort);
                }

                mainDic.SetLong("HeartBtInt", _config.HeartBtInt);
                mainDic.SetLong("ReconnectInterval", _config.ReconnectInterval);
                mainDic.SetString("FileStorePath", _config.FileStorePath);
                logger.Debug("FileLogPath: " + _config.FileLogPath);
                mainDic.SetString("FileLogPath", _config.FileLogPath);
                logger.Debug("DebugFileLogPath: " + _config.FileLogPath);
                mainDic.SetString("DebugFileLogPath", _config.DebugFileLogPath);
                mainDic.SetString("StartTime", _config.StartTime);
                mainDic.SetString("EndTime", _config.EndTime);
                mainDic.SetString("ConnectionType", "acceptor");


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

                settings.Set(mainDic);

                foreach (FixSessionItem info in _sessionsDropCopy)
                {
                    Dictionary sessDic       = new Dictionary();
                    string     strdictionary = path + Path.DirectorySeparatorChar + info.DataDictionary;

                    sessDic.SetString("DataDictionary", strdictionary);
                    sessDic.SetBool("UseDataDictionary", info.UseDataDictionary);
                    sessDic.SetBool("ResetOnLogon", info.ResetSeqNum);
                    sessDic.SetBool("PersistMessages", info.PersistMessages);

                    logger.InfoFormat("Criando sessao DROPCOPY S:[{0}] T:[{1}] UseDic:[{2}] Dic:[{3}] Rst:[{4}] Pers:[{5}] Begstr:[{6}] FinancialLimit:[{7}] Port:[{8}] IdClient[{9}]",
                                      info.SenderCompID,
                                      info.TargetCompID,
                                      info.UseDataDictionary,
                                      strdictionary,
                                      info.ResetSeqNum,
                                      info.PersistMessages,
                                      info.BeginString,
                                      info.FinancialLimit,
                                      info.Operador,
                                      info.IdCliente
                                      );

                    // Adicionar no dicionario para validacao de logon
                    // Atribui respectivo Initiator para cada sessao
                    SessionDropCopy ssDrop = new SessionDropCopy();
                    //FixInitiator aux = null;
                    //foreach (FixInitiator init in _lstInitiator)
                    //{
                    //    if (init.Canal == info.Operador)
                    //    {
                    //        aux = init;
                    //        break;
                    //    }
                    //}
                    ssDrop.Config = info;

                    //ssDrop.Initiator = aux;
                    //ssDrop.CalcularLimite = info.FinancialLimit;

                    /*
                     */
                    SessionID session = new SessionID(info.BeginString, info.TargetCompID, info.SenderCompID);
                    ssDrop.Sessao = session;
                    ssDrop.Start();
                    //_dicSessionsDropCopy.Add(session, ssDrop);

                    List <SessionDropCopy> lstDC = null;
                    if (_dicSessionsDropCopy.TryGetValue(info.Operador, out lstDC))
                    {
                        lstDC.Add(ssDrop);
                    }
                    else
                    {
                        List <SessionDropCopy> lst = new List <SessionDropCopy>();
                        lst.Add(ssDrop);
                        _dicSessionsDropCopy.Add(info.Operador, lst);
                    }
                    // Adicionar a sessao no initiator, para conseguir "referencia cruzada"
                    // Verificar se nao ocorre erros
                    //if (null != aux)
                    //{
                    //    ssAcceptor.Initiator.AddSessionAcceptor(session, ssAcceptor);
                    //}
                    settings.Set(session, sessDic);
                }

                //FileStoreFactory store = new FileStoreFactory(settings);
                MemoryStoreFactory store = new MemoryStoreFactory();

                FileLogFactory  logs = new FileLogFactory(settings);
                IMessageFactory msgs = new DefaultMessageFactory();

                logger.Info("Iniciando ThreadedSocketAcceptor ...");
                _socketDropCopy = new ThreadedSocketAcceptor(this, store, settings, logs, msgs);
                _socketDropCopy.Start();
                logger.Info("Start(): ThreadedSocketAcceptor em execucao....");


                logger.Info("Start(): Iniciando thread de mensagens....");
                // Thread para receber as mensagens de acceptors
                _thDropCopy          = new Thread(new ThreadStart(this.SendToDropCopy));
                _thDropCopy.Priority = ThreadPriority.Normal;
                _thDropCopy.Start();
                logger.Info("Start(): thread de mensagens iniciada....");

                logger.Info("FixDropCopy Start(): Fim de Inicializacao do ThreadedSocketAcceptor....");
            }
            catch (Exception ex)
            {
                logger.Error("Problemas no start da sessao FixDropCopy: " + ex.Message, ex);
                throw ex;
            }
        }
コード例 #29
0
ファイル: FixServerAcceptor.cs プロジェクト: radtek/Gradual
        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!");
        }