Inheritance: MessageStoreFactory
Esempio n. 1
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);
            }
        }
Esempio n. 2
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());
            }
        }
Esempio n. 3
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 );
    }
  }
Esempio n. 4
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());
            }
        }
Esempio n. 5
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());
            }
        }
Esempio n. 6
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);
 }
Esempio n. 7
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;
 }
Esempio n. 8
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();
            }
            
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
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();
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
 }
        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;
        }
Esempio n. 16
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;
            }
        }
Esempio n. 17
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);
        }
Esempio n. 18
0
        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;
            }
        }
Esempio n. 19
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 );
  }
Esempio n. 20
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);
        }
Esempio n. 21
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());
            }
        }
Esempio n. 23
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);
        }
Esempio n. 24
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());
            }
        }
Esempio n. 25
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);
            }
        }
Esempio n. 26
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());
            }
        }
Esempio n. 27
0
        public void ThreadSafeSetAndGet()
        {
            //Set up store
            if (System.IO.Directory.Exists("store")) {
                System.IO.Directory.Delete("store", true);
            }

            SessionID sessionId = new SessionID("FIX.4.2", "SENDERCOMP", "TARGETCOMP");

            Dictionary config = new Dictionary();
            config.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
            config.SetString(SessionSettings.FILE_STORE_PATH, "store");

            SessionSettings settings = new SessionSettings();
            settings.Set(sessionId, config);
            FileStoreFactory factory = new FileStoreFactory(settings);

            FileStore store = (FileStore)factory.Create(sessionId);

            NullLog log = new NullLog();

            //Set up sessionstate
            SessionState state = new SessionState(log, 1) {MessageStore = store};

            Hashtable errorsTable = Hashtable.Synchronized(new Hashtable());//used in more than 1 thread at a time
            Hashtable setTable = new Hashtable(1000);//only used in 1 thread at a time
            Hashtable getTable = new Hashtable(1000);//only used in 1 thread at a time

            //Synchronously populate 1000 messages
            for (int i = 1; i < 1000; i++) {
                string msg = "msg" + i;
                state.Set(i, msg);
                setTable[i] = msg;
            }

            //Simulate background sending of messages that populate into the store
            AutoResetEvent setEvent = new AutoResetEvent(false);
            ThreadPool.QueueUserWorkItem(delegate(object stateObject) {
                AutoResetEvent internalSetEvent = (AutoResetEvent)((object[])stateObject)[0];
                SessionState internalState = (SessionState)((object[])stateObject)[1];
                for (int i = 1001; i < 2000; i++) {
                    try {
                        internalState.Set(i, "msg" + i);
                    }
                    catch (System.IO.IOException ex) {
                        errorsTable[ex.Message] = ex;
                    }
                }

                internalSetEvent.Set();
            }
            , new object[] { setEvent, state });

            //Simulate background reading of messages from the store - like is done in a resend request answer
            AutoResetEvent getEvent = new AutoResetEvent(false);
            ThreadPool.QueueUserWorkItem(delegate(object stateObject){
                AutoResetEvent internalGetEvent = (AutoResetEvent)((object[])stateObject)[0];
                SessionState internalState = (SessionState)((object[])stateObject)[1];
                for (int i = 1; i < 1000; i++) {
                    try {
                        List<string> lst = new List<string>(1);
                        internalState.Get(i, i, lst);
                        if (lst.Count == 0) {
                            getTable[i] = "nothing read";
                        }
                        else {
                            getTable[i] = lst[0];
                        }
                    }
                    catch (System.IO.IOException ex) {
                        errorsTable[ex.Message] = ex;
                    }
                }

                internalGetEvent.Set();
            }
            , new object[]{getEvent, state});

            //wait till done and assert results
            Assert.True(setEvent.WaitOne(10000), "Get or Set hung/timed out during concurrent usage");
            Assert.True(getEvent.WaitOne(10000), "Get or Set hung/timed out during concurrent usage");
            Assert.AreEqual(setTable, getTable, "Garbled data read  in concurrent set and get (like between resendrequest and send)");
            Assert.AreEqual(errorsTable.Count, 0, "IOException occured in concurrent set and get (like between resendrequest and send)");

            //Tear down filestore
            state.Dispose();
            store.Dispose();
        }
Esempio n. 28
0
        public static void Main2(string[] args)
        {
            BTCCFIXClientApp app = new BTCCFIXClientApp();
            string sessionFile = Environment.CurrentDirectory+"/session_client.txt";
            SessionSettings settings = new SessionSettings(sessionFile);
            IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
            ILogFactory logFactory = new FileLogFactory(settings);
            QuickFix.Transport.SocketInitiator initiator = new QuickFix.Transport.SocketInitiator(app, storeFactory, settings, logFactory);
            initiator.Start();

            BTCCMarketDataRequest btccDataRequest = new BTCCMarketDataRequest();

            System.Threading.Thread.Sleep(5000);
            //request full snapshot
            MarketDataRequest dataRequest = btccDataRequest.marketDataFullSnapRequest("BTCCNY");
            bool ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataFullSnapRequest("LTCBTC");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            System.Threading.Thread.Sleep(15000);
            //request incremental request
            dataRequest = btccDataRequest.marketDataIncrementalRequest("BTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.marketDataIncrementalRequest("LTCBTC");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            System.Threading.Thread.Sleep(40000);
            //unsubscribe incremental request
            dataRequest = btccDataRequest.unsubscribeIncrementalRequest("BTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCCNY");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);

            dataRequest = btccDataRequest.unsubscribeIncrementalRequest("LTCBTC");
            ret = Session.SendToTarget(dataRequest, app.m_sessionID);
            Console.WriteLine("SendToTarget ret={0}", ret);
        }
Esempio n. 29
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);
     }
 }
Esempio n. 30
0
 public bool Start(string user, string pw)
 {
     try
     {
         SessionSettings settings = new SessionSettings(_setpath);
         Application application = this;
         FileStoreFactory storeFactory = new FileStoreFactory(settings);
         FileLogFactory logFactory = new FileLogFactory(settings);
         MessageFactory messageFactory = new DefaultMessageFactory();
         acceptor = new SocketAcceptor
           (application, storeFactory, settings, logFactory /*optional*/, messageFactory);
         acceptor.start();
         _val = true;
         return true;
     }
     catch (Exception ex)
     {
         debug("exception starting server: " + ex.Message + ex.StackTrace);
         _val = false;
     }
     return false;
 }
Esempio n. 31
0
        static SocketInitiator StartSocketInitiator(String configFile)
        {
            ClientInitiator app = new ClientInitiator();
            SessionSettings settings = new SessionSettings(configFile);
            QuickFix.Application application = new ClientInitiator();
            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();
            Thread.Sleep(3000);
            return initiator;
        }