/*
         *
         * instrument quickfix_id => list of fixconnectors
         */
        static public void OnStartUp(NinjaTrader.Strategy.FixConnector fixConnector)
        {
            lock (locker_)
            {
                // adding anyway
                s_fixConnectors.Add(fixConnector);

                try
                {
                    // start ?
                    if (string.IsNullOrEmpty(ConfigFileName))
                    {
                        if (string.IsNullOrEmpty(fixConnector.ConfigFileName))
                        {
                            // cannot start
                            s_fixConnectors.Warn(Name, "No config file name set to start QuickFix server. FixConnector enqueued but inactive for now ...");
                            return;
                        }

                        // a configfile is set, let's spin that shit
                        ConfigFileName = fixConnector.ConfigFileName;
                        s_fixConnectors.Info(Name, "[OnStartUp] Creating FIX session with file " + ConfigFileName);
                        QuickFix.SessionSettings sessionSettings = new QuickFix.SessionSettings(ConfigFileName);

                        s_fixConnectors.Info(Name, "[OnStartUp] Creating socket acceptor");
                        m_acceptor = new QuickFix.ThreadedSocketAcceptor(
                            m_app  = new NinjaTrader_FixBridge.QuickFixApp(s_fixConnectors),
                            new QuickFix.FileStoreFactory(sessionSettings),
                            sessionSettings,
                            new QuickFix.FileLogFactory(sessionSettings)
                            );

                        sessionSettings = null;

                        s_fixConnectors.Info(Name, "[OnStartUp] Starting FixBridge ...");
                        m_acceptor.Start();
                        s_fixConnectors.Info(Name, "[OnStartUp] FixBridge started !");
                    }
                }
                catch (Exception e)
                {
                    s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.Message + ", source:" + e.Source);
                    s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.ToString());
                    s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.StackTrace);
                    s_fixConnectors.Error(Name, "[OnStartUp]  => destroying FIX layer");

                    KillFix();
                    throw e;
                }
            }
        }
        static public void KillFix()
        {
            lock (locker_)
            {
                if (m_app != null)
                {
                    m_app.Dispose();
                    m_app = null;
                }

                if (m_acceptor != null)
                {
                    m_acceptor.Stop(true);
                    m_acceptor.Dispose();
                    m_acceptor = null;
                }
            }
        }
        public static void KillFix()
        {
            lock (locker_)
            {
                if (m_app != null)
                {
                    m_app.Dispose();
                    m_app = null;
                }

                if (m_acceptor != null)
                {
                    m_acceptor.Stop(true);
                 //   m_acceptor.Dispose();
                    m_acceptor = null;
                }

            }
        }
        /*
         *
         * instrument quickfix_id => list of fixconnectors
         */
        public static void OnStartUp(NinjaTrader.Strategy.FixConnector fixConnector)
        {
            lock (locker_)
            {
            // adding anyway
            s_fixConnectors.Add(fixConnector);

            try
            {
                // start ?
                if (string.IsNullOrEmpty(ConfigFileName))
                {

                    if (string.IsNullOrEmpty(fixConnector.ConfigFileName))
                    {
                        // cannot start
                        s_fixConnectors.Warn(Name, "No config file name set to start QuickFix server. FixConnector enqueued but inactive for now ...");
                        return;
                    }

                    // a configfile is set, let's spin that shit
                    ConfigFileName = fixConnector.ConfigFileName;
                    s_fixConnectors.Info(Name, "[OnStartUp] Creating FIX session with file " + ConfigFileName);
                    QuickFix.SessionSettings sessionSettings = new QuickFix.SessionSettings(ConfigFileName);

                    s_fixConnectors.Info(Name, "[OnStartUp] Creating socket acceptor");
                    m_acceptor = new QuickFix.ThreadedSocketAcceptor(
                        m_app=new NinjaTrader_FixBridge.QuickFixApp(s_fixConnectors),
                        new QuickFix.FileStoreFactory(sessionSettings),
                        sessionSettings,
                        new QuickFix.FileLogFactory(sessionSettings)
                        );

                    sessionSettings = null;

                    s_fixConnectors.Info(Name, "[OnStartUp] Starting FixBridge ...");
                    m_acceptor.Start();
                    s_fixConnectors.Info(Name, "[OnStartUp] FixBridge started !");
                }
            }
            catch (Exception e)
            {
                s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.Message + ", source:" + e.Source);
                s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.ToString());
                s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.StackTrace);
                s_fixConnectors.Error(Name, "[OnStartUp]  => destroying FIX layer");

                KillFix();
                throw e;
            }
            }
        }