Esempio n. 1
0
        public void SetUp()
        {
            try
            {
                MamaBridge mBridge = Mama.loadBridge("lbm");
                Mama.open();

                MamaDictionary mDictionary = new MamaDictionary();
                mDictionary.create("dictionary.txt");

                MamdaCommonFields.setDictionary(mDictionary, null);
                MamdaQuoteFields.reset();
                MamdaQuoteFields.setDictionary(mDictionary, null);

                mSubscription  = new MamdaSubscription();
                mQuoteListener = new MamdaQuoteListener();
                mSubscription.addMsgListener(mQuoteListener);

                ticker = new QuoteTicker();
                mQuoteListener.addHandler(ticker);
            }
            catch (Exception ex)
            {
                throw new MamdaDataException(ex.Message, ex);
            }
        }
Esempio n. 2
0
        public void SetUp()
        {
            try
            {
                //Intialise mama
                myBridge = new MamaBridge("lbm");
                Mama.open();

                mDictionary = new MamaDictionary();
                mDictionary.create("dictionary.txt");

                MamdaCommonFields.setDictionary(mDictionary, null);
                MamdaTradeFields.reset();
                MamdaTradeFields.setDictionary(mDictionary, null);

                mSubscription  = new MamdaSubscription();
                mTradeListener = new MamdaTradeListener();
                mSubscription.addMsgListener(mTradeListener);

                ticker = new tradetickerCB();
                mTradeListener.addHandler(ticker);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            ListenerCallback     callback     = new ListenerCallback();
            CommandLineProcessor options      = new CommandLineProcessor(args);

            try
            {
                // Initialize MAMA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                if (options.hasLogLevel())
                {
                    Mama.enableLogging(options.getLogLevel());
                }

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription();

                    aSubscription.addMsgListener(callback);
                    aSubscription.addStaleListener(callback);
                    aSubscription.addErrorListener(callback);

                    if (options.getSnapshot())
                    {
                        aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0);
                    }

                    aSubscription.create(transport,
                                         defaultQueue,
                                         options.getSource(),
                                         symbol,
                                         null);
                    mamdaSubscriptions.Add(aSubscription);
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            MamaTransport transport = null;
            MamaQueue defaultQueue = null;
            MamaDictionary dictionary = null;
            ListenerCallback callback = new ListenerCallback();
            CommandLineProcessor options = new CommandLineProcessor(args);

            try
            {
                // Initialize MAMA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open ();
                if (options.hasLogLevel())
                {
                    Mama.enableLogging (options.getLogLevel());
                }

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription ();

                    aSubscription.addMsgListener(callback);
                    aSubscription.addStaleListener(callback);
                    aSubscription.addErrorListener(callback);

                    if (options.getSnapshot())
                        aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0);

                    aSubscription.create(transport,
                                        defaultQueue,
                                        options.getSource(),
                                        symbol,
                                        null);
                    mamdaSubscriptions.Add(aSubscription);
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 5
0
        public void Setup()
        {
            mBridge = Mama.loadBridge("lbm");
            Mama.open();

            // Create the message
            m_msg = new MamaMsg();

            // Create the array of messages
            m_vectorMsg  = InitialiseMessageArray(m_numberMessages, 69);
            m_vectorMsg2 = InitialiseMessageArray(m_numberMessages, 144);
        }
Esempio n. 6
0
        public void Setup()
        {
            MamaCommon.getCmdLineArgs();

            mBridge = Mama.loadBridge(MamaCommon.middlewareName);
            Mama.open();

            // Create the message
            m_msg = new MamaMsg();

            // Create the array of messages
            m_vectorMsg  = InitialiseMessageArray(m_numberMessages, 69);
            m_vectorMsg2 = InitialiseMessageArray(m_numberMessages, 144);
        }
Esempio n. 7
0
        private static void initializeMama()
        {
            Mama.enableLogging(mamaLogLevel);

            try
            {
                myBridge = Mama.loadBridge(myMiddleware);

                /* Always the first API method called. Initialized internal API
                 * state*/
                Mama.open();
                myDefaultQueue = Mama.getDefaultEventQueue(myBridge);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Failed to initialize MAMA");
                Environment.Exit(1);
            }

            transport = new MamaTransport();

            /* The name specified here is the name identifying properties in the
             * mama.properties file*/
            transport.create(transportName, myBridge);

            if (myDictTportName != null)
            {
                myDictTransport = new MamaTransport();
                myDictTransport.create(myDictTportName, myBridge);
            }
            else
            {
                myDictTransport = transport;
            }

            /*MamaSource for all subscriptions*/
            mySource                 = new MamaSource();
            mySource.transport       = transport;
            mySource.symbolNamespace = mySymbolNamespace;

            /*MamaSource for dictionary subscription*/
            myDictSource                 = new MamaSource();
            myDictSource.transport       = myDictTransport;
            myDictSource.symbolNamespace = dictSource;
        }
        public void SetUp()
        {
            try
            {
                MamaBridge mBridge = Mama.loadBridge("lbm");
                Mama.open();

                MamaDictionary mDictionary = new MamaDictionary();
                mDictionary.create("dictionary.txt");

                MamdaCommonFields.setDictionary(mDictionary, null);
                MamdaSecurityStatusFields.reset();
                MamdaSecurityStatusFields.setDictionary(mDictionary, null);

                mSubscription = new MamdaSubscription();
            }
            catch (Exception ex)
            {
                throw new MamdaDataException(ex.Message, ex);
            }
        }
Esempio n. 9
0
        public void Setup()
        {
            // Load the wmw bridge
            m_bridge = Mama.loadBridge("lbm");

            // Create the mama queue
            m_queue = new MamaQueue(m_bridge);

            // Create the auto reset event
            m_event = new AutoResetEvent(false);

            // Spin a thread to dispatch events
            m_dispatcher = new Thread(new ThreadStart(this.DispatcherThread));

            // Reset all other member variables
            m_closure      = null;
            m_numberEvents = 0;

            // Start the thread
            m_dispatcher.Start();
        }
Esempio n. 10
0
        /// <summary>
        /// This function will initialise mama including loading the bridge and creating the queues and transports.
        /// </summary>
        private void initializeMama()
        {
            // Set the desired log level, (based on the number of 'v's passed on the command line)
            Mama.enableLogging(m_logLevel);

            m_bridge = Mama.loadBridge(m_middlewareName);

            Console.WriteLine(Mama.getVersion(m_bridge));

            Mama.open();

            m_defaultQueue = Mama.getDefaultEventQueue(m_bridge);

            // The transport must be created before the dictionary is downloaded
            createTransport();

            createDictionary();

            createQueues();

            // Create the source needed to establish market data subscriptions
            createSource();
        }
Esempio n. 11
0
        public void Setup()
        {
            // Set the logging to this level
            Mama.enableLogging(MamaLogLevel.MAMA_LOG_LEVEL_FINEST);

            MamaCommon.getCmdLineArgs();

            createCount  = 0;
            errorCount   = 0;
            destroyCount = 0;

            // Load the wmw bridge
            m_bridge = Mama.loadBridge(MamaCommon.middlewareName);

            Mama.open();

            Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINE, "MamaPublisherTest.Setup: transport=" +
                     MamaCommon.middlewareName + " tport=" + MamaCommon.transportName +
                     " source=" + MamaCommon.source + " symbol=" + MamaCommon.symbol);

            // Create the mama queue
            m_queueGroup = new MamaQueueGroup(m_bridge, 1);

            m_msg = new MamaMsg();

            m_transport = new MamaTransport();
            m_transport.create(MamaCommon.transportName, m_bridge);

            Mama.startBackground(m_bridge, this);

            Thread.Sleep(1000);

            GC.KeepAlive(m_bridge);
            GC.KeepAlive(m_transport);
            GC.KeepAlive(m_queueGroup);
            GC.KeepAlive(m_msg);
        }
Esempio n. 12
0
        public void SetUp()
        {
            try
            {
                MamaBridge mBridge = Mama.loadBridge("lbm");
                Mama.open();

                MamaDictionary mDictionary = new MamaDictionary();
                mDictionary.create("dictionary.txt");

                MamdaCommonFields.setDictionary(mDictionary, null);
                MamdaTradeFields.reset();
                MamdaTradeFields.setDictionary(mDictionary, null);

                mSubscription  = new MamdaSubscription();
                mTradeListener = new MamdaTradeListener();
                mSubscription.addMsgListener(mTradeListener);
                recap = new MamdaConcreteTradeRecap();
            }
            catch (Exception ex)
            {
                throw new MamdaDataException(ex.Message, ex);
            }
        }
Esempio n. 13
0
        public static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);
            myQuietModeLevel				  = options.getQuietModeLevel();

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                /*Get the data dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaAuctionFields.setDictionary(dictionary, null);

                mamdaSubscriptions = new MamdaSubscription [options.getSymbolList().Count];
                int i=0;
                foreach (string symbol in options.getSymbolList())
                {
                    mamdaSubscriptions[i] =  new MamdaSubscription();
                    MamdaAuctionListener aAuctionListener = new MamdaAuctionListener();
                    AuctionTicker        aTicker        = new AuctionTicker();

                    aAuctionListener.addHandler(aTicker);
                    mamdaSubscriptions[i].addMsgListener(aAuctionListener);
                    mamdaSubscriptions[i].addStaleListener(aTicker);
                    mamdaSubscriptions[i].addErrorListener(aTicker);

                    mamdaSubscriptions[i].create(transport,
                                        defaultQueue,
                                        options.getSource (),
                                        symbol,
                                        null);
                    i++;
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 14
0
        private void initializeMama()
        {
            mamaBridge = Mama.loadBridge(mamaMiddlewareName);

            Console.WriteLine(Mama.getVersion(mamaBridge));

            Mama.open();

            if (mamaHighWaterMark > 0 || mamaLowWaterMark > 0)
            {
                if (mamaHighWaterMark > 0)
                {
                    Mama.setDefaultQueueHighWatermark(mamaHighWaterMark);
                }

                if (mamaLowWaterMark > 0)
                {
                    try
                    {
                        Mama.setDefaultQueueLowWatermark(mamaLowWaterMark);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Could not set default queue low water mark MamaStatus: " + e);
                    }
                }
            }

            // create the transport
            mamaTransport = new MamaTransport();

            mamaTransport.setTransportCallback(this);

            // the default throttle rate is 500 msg/sec
            if (mamaThrottle != -1)
            {
                mamaTransport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_DEFAULT, mamaThrottle);
            }

            // the default recap throttle rate is 250 msg/sec
            if (mamaRecapThrottle != -1)
            {
                mamaTransport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_RECAP, mamaRecapThrottle);
            }

            mamaTransport.create(mamaTransportName, mamaBridge);

            // create default queue and, if required, queue group
            createQueues();

            mamaDictionarySource = new MamaSource();
            mamaDictionarySource.symbolNamespace = mamaDictionarySourceName;
            mamaDictionarySource.transport       = mamaTransport;

            // download dictionary
            mamaDictionary = new MamaDictionary();

            mamaDictionary.create(
                mamaDefaultQueue,
                this,
                mamaDictionarySource,
                3,
                10.0f);

            loadSymbolMap();

            Mama.start(mamaBridge);

            if (!dictionaryComplete)
            {
                throw new Exception("Can't create dictionary.");
            }
        }
        public static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);
            double throttleRate = options.getThrottleRate();


            if (options.hasLogLevel())
            {
                logLevel_ = options.getLogLevel();
                Mama.enableLogging(logLevel_);
            }

            if ((throttleRate > 100.0) || (throttleRate <= 0.0))
            {
                throttleRate = 100.0;
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                //Initialise the dictionary and fields
                MamdaCommonFields.setDictionary(dictionary, null);
                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription();
                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP);
                    aSubscription.setTimeout(60.0);
                    aSubscription.create(
                        transport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);

                    /* For each subscription a MamdaMultiSecurityicipantManager is
                     * added as the message listener. The callbacks on the
                     * MamdaMultiSecurityHandler will be invokes as new group members
                     * become available.*/
                    MamdaMultiSecurityManager multiSecurityManager =
                        new MamdaMultiSecurityManager(symbol);
                    multiSecurityManager.addHandler(new MultiSecurityHandler());

                    aSubscription.addMsgListener(multiSecurityManager);

                    aSubscription.activate();

                    mamdaSubscriptions.Add(aSubscription);
                }

                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.WriteLine("Press ENTER or Ctrl-C to quit...");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
        public static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);

            myQuietModeLevel = options.getQuietModeLevel();

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                /*Get the data dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaAuctionFields.setDictionary(dictionary, null);

                mamdaSubscriptions = new MamdaSubscription [options.getSymbolList().Count];
                int i = 0;
                foreach (string symbol in options.getSymbolList())
                {
                    mamdaSubscriptions[i] = new MamdaSubscription();
                    MamdaAuctionListener aAuctionListener = new MamdaAuctionListener();
                    AuctionTicker        aTicker          = new AuctionTicker();

                    aAuctionListener.addHandler(aTicker);
                    mamdaSubscriptions[i].addMsgListener(aAuctionListener);
                    mamdaSubscriptions[i].addStaleListener(aTicker);
                    mamdaSubscriptions[i].addErrorListener(aTicker);

                    mamdaSubscriptions[i].create(transport,
                                                 defaultQueue,
                                                 options.getSource(),
                                                 symbol,
                                                 null);
                    i++;
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 17
0
 internal KillTimerCallback(MamaBridge bridge)
 {
     // Save arguments in member variables
     m_bridge = bridge;
 }
Esempio n. 18
0
        public static void Main(string[] args)
        {
            MamaTransport        transport          = null;
            MamaTransport        dictTransport      = null;
            string               dictTransportName  = null;
            MamaQueue            defaultQueue       = null;
            MamaDictionary       dictionary         = null;
            CommandLineProcessor options            = new CommandLineProcessor(args);

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                myMamaSource = new MamaSource ();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = transport;
                }
                dictionarySource.transport = dictTransport;

                /*Get the data dictionary*/
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);

                MamdaSecurityStatusFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription  aSubscription =  new MamdaSubscription();
                    MamdaSecurityStatusListener aSecListener = new MamdaSecurityStatusListener();
                    SecTicker        aTicker        = new SecTicker();

                    aSecListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aSecListener);

                    aSubscription.create(transport,
                                        defaultQueue,
                                        options.getSource (),
                                        symbol,
                                        null);
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
        public static void Main(string[] args)
        {
            MamaTransport        transport         = null;
            MamaTransport        dictTransport     = null;
            string               dictTransportName = null;
            MamaQueue            defaultQueue      = null;
            MamaDictionary       dictionary        = null;
            CommandLineProcessor options           = new CommandLineProcessor(args);

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport    = new MamaTransport();
                myMamaSource = new MamaSource();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = transport;
                }
                dictionarySource.transport = dictTransport;

                /*Get the data dictionary*/
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);

                MamdaFundamentalFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription        aSubscription = new MamdaSubscription();
                    MamdaFundamentalListener aSecListener  = new MamdaFundamentalListener();
                    FundTicker aTicker = new FundTicker();

                    aSecListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aSecListener);

                    aSubscription.create(transport,
                                         defaultQueue,
                                         options.getSource(),
                                         symbol,
                                         null);
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            MamaTransport        transport = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary = null;
            CommandLineProcessor options = new CommandLineProcessor (args);
            myQuietModeLevel = options.getQuietModeLevel ();

            if (options.hasLogLevel ())
            {
                myLogLevel = options.getLogLevel ();
                Mama.enableLogging (myLogLevel);
            }

            try
            {
                //Initialize MAMA API
                myBridge = new MamaBridge (options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                myMamaSource = new MamaSource ();
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource ();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaQuoteFields.setDictionary (dictionary, null);
                MamdaTradeFields.setDictionary (dictionary, null);
                MamdaCommonFields.setDictionary (dictionary, null);
                MamdaOrderBookFields.setDictionary (dictionary, null);

                myQueueGroup = new MamaQueueGroup (myBridge, options.getNumThreads());

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription  aSubscription = new MamdaSubscription ();

                    MamdaBookAtomicListener aBookListener = new MamdaBookAtomicListener();
                    AtomicBookTicker        aTicker       = new AtomicBookTicker ();

                    aBookListener.addBookHandler (aTicker);
                    aBookListener.addLevelHandler (aTicker);

                    if (options.getPrintEntries())
                    {   // Entries
                        aBookListener.addLevelEntryHandler (aTicker);
                    }

                    aSubscription.addMsgListener (aBookListener);
                    aSubscription.addStaleListener (aTicker);
                    aSubscription.addErrorListener (aTicker);
                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);

                    aSubscription.create (transport,
                                          myQueueGroup.getNextQueue(),
                                          options.getSource (),
                                          symbol,
                                          null);

                    mamdaSubscriptions.Add(aSubscription);
                }

                //Start dispatching on the default MAMA event queue
                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start (myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Environment.Exit(1);
                }
        }
        static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);

            myQuietModeLevel = options.getQuietModeLevel();


            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            try
            {
                //Initialize MAMA API
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                myMamaSource = new MamaSource();
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);
                MamdaCommonFields.setDictionary(dictionary, null);
                MamdaOrderBookFields.setDictionary(dictionary, null);

                myQueueGroup = new MamaQueueGroup(myBridge, options.getNumThreads());

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription();

                    MamdaBookAtomicListener aBookListener = new MamdaBookAtomicListener();
                    AtomicBookTicker        aTicker       = new AtomicBookTicker();

                    aBookListener.addBookHandler(aTicker);
                    aBookListener.addLevelHandler(aTicker);

                    if (options.getPrintEntries())
                    {   // Entries
                        aBookListener.addLevelEntryHandler(aTicker);
                    }

                    aSubscription.addMsgListener(aBookListener);
                    aSubscription.addStaleListener(aTicker);
                    aSubscription.addErrorListener(aTicker);
                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);

                    aSubscription.create(transport,
                                         myQueueGroup.getNextQueue(),
                                         options.getSource(),
                                         symbol,
                                         null);

                    mamdaSubscriptions.Add(aSubscription);
                }

                //Start dispatching on the default MAMA event queue
                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            // Parse the command line options to override defaults
            String middlewareName     = "qpid";
            String transportName      = "sub";
            String sourceName         = "OM";
            String symbolName         = null;
            String dictionaryFile     = "/opt/openmama/data/dictionaries/data.dict";
            bool   requiresDictionary = true;
            bool   requiresInitial    = true;

            if (args.Length == 0)
            {
                usageAndExit();
            }

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-B":
                    requiresDictionary = false;
                    break;

                case "-d":
                    dictionaryFile = args[++i];
                    break;

                case "-I":
                    requiresInitial = false;
                    break;

                case "-m":
                    middlewareName = args[++i];
                    break;

                case "-s":
                    symbolName = args[++i];
                    break;

                case "-S":
                    sourceName = args[++i];
                    break;

                case "-t":
                    transportName = args[++i];
                    break;

                case "-v":
                    Mama.enableLogging(MamaLogLevel.MAMA_LOG_LEVEL_FINEST);
                    break;

                default:
                    usageAndExit();
                    break;
                }
            }

            // Symbol name is mandatory here, so error if it's null
            if (symbolName == null)
            {
                usageAndExit();
            }

            // Load the requested OpenMAMA middleware bridge (and default payload too)
            MamaBridge bridge = Mama.loadBridge(middlewareName);

            // Time to initialize OpenMAMA's underlying bridges with an "open"
            Mama.open();

            // Get default event queue from the bridge for testing
            MamaQueue queue = Mama.getDefaultEventQueue(bridge);

            // Set up the required transport on the specified bridge
            MamaTransport transport = new MamaTransport();

            transport.create(transportName, bridge);

            // Set up the data dictionary
            MamaDictionary dictionary = null;

            if (requiresDictionary)
            {
                dictionary = new MamaDictionary();
                dictionary.create(dictionaryFile);
            }

            // Set up the OpenMAMA source (symbol namespace)
            MamaSource source = new MamaSource();

            source.symbolNamespace = sourceName;
            source.transport       = transport;

            // Set up the event handlers for OpenMAMA
            SubscriptionEventHandler eventHandler = new SubscriptionEventHandler();

            eventHandler.mDictionary = dictionary;

            // Set up the OpenMAMA Subscription (interest in a topic)
            MamaSubscription subscription = new MamaSubscription();

            subscription.setRequiresInitial(requiresInitial);
            subscription.create(queue, eventHandler, source, symbolName);

            // Kick off OpenMAMA now (blocking call, non-blocking call also available)
            Mama.start(bridge);

            // Clean up connection on termination
            Mama.close();
        }
Esempio n. 23
0
        public static void Main(string[] args)
        {
            try
            {
                options = new CommandLineProcessor(args);

                //Getting the log File name
                myLogFileName = options.getLogFileName();

                if (myLogFileName != null)
                {
                    myOutFile = new FileStream(myLogFileName, FileMode.OpenOrCreate);
                    myOut     = new StreamWriter(myOutFile);
                    myOut.WriteLine("Date/Time" + "," + "ChurnStats" + ","
                                    + "UpdateStats" + "," + "PeakMsgCount" + ","
                                    + "RecapStats" + "," + "BookGapStats" + ","
                                    + "freeMemory" + "," + "Memory Used");
                }
                else
                {
                    myOut = Console.Out;
                }

                // Initialize MAMA
                bridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                if (options.hasLogLevel())
                {
                    myLogLevel = options.getLogLevel();
                    Mama.enableLogging(myLogLevel);
                }

                transport = new MamaTransport();
                transport.create(options.getTransport(), bridge);

                defaultQueue = Mama.getDefaultEventQueue(bridge);

                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaOrderBookFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    subscribeToBooks(symbol);
                }

                myChurnRate = options.getChurnRate();

                Thread.Sleep(10000);

                //Getting the TimerInterval from the cmd prompt
                myChurnInterval = options.getTimerInterval();

                //Churn Timer
                if (myChurnRate > 0)
                {
                    myChurnTimer = safeCreateTimer(new ChurnCallback(), myChurnInterval);
                }

                //Stats Timer
                myStatsTimer = safeCreateTimer(new StatsCallback(), 1.0);

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(bridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();

                if (myOutFile != null)
                {
                    myOut.Close();
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 24
0
 internal ListenerDictionaryCallback(MamaBridge bridge)
 {
     // Save arguments in member variables
     m_bridge = bridge;
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);

            myQuietModeLevel = options.getQuietModeLevel();


            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            myCacheFullBooks = options.cacheFullBooks();
            myPrintEntries   = options.getPrintEntries();
            mySnapshot       = options.getSnapshot();
            myPrecision      = options.getPrecision();
            try
            {
                //Initialize MAMA API
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                myMamaSource = new MamaSource();
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaOrderBookFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription      aSubscription = new MamdaSubscription();
                    MamdaOrderBookListener aBookListener;
                    if (myCacheFullBooks)
                    {
                        aBookListener = new MamdaOrderBookListener();
                    }
                    else
                    {
                        aBookListener = new MamdaOrderBookListener(null, new MamdaOrderBook());
                    }

                    BookTicker aTicker = new BookTicker();

                    aBookListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aBookListener);
                    aSubscription.addStaleListener(aTicker);
                    aSubscription.addErrorListener(aTicker);

                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);
                    if (mySnapshot)
                    {
                        aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0);
                    }
                    aSubscription.create(
                        transport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);

                    mamdaSubscriptions.Add(aSubscription);
                }

                //Start dispatching on the default MAMA event queue
                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 26
0
        public static void Main(string[] args)
        {
            try
            {
                options = new CommandLineProcessor(args);

                //Getting the log File name
                myLogFileName = options.getLogFileName();

                if (myLogFileName != null)
                {
                    myOutFile = new FileStream(myLogFileName, FileMode.OpenOrCreate);
                    myOut = new StreamWriter(myOutFile);
                    myOut.WriteLine("Date/Time"+ "," + "ChurnStats" +","
                        + "UpdateStats" + "," + "PeakMsgCount" + ","
                        + "RecapStats" + "," + "BookGapStats" + ","
                        +"freeMemory" +"," +"Memory Used");
                }
                else
                {
                    myOut = Console.Out;
                }

                // Initialize MAMA
                bridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                if (options.hasLogLevel())
                {
                    myLogLevel = options.getLogLevel();
                    Mama.enableLogging(myLogLevel);
                }

                transport = new MamaTransport();
                transport.create(options.getTransport(), bridge);

                defaultQueue = Mama.getDefaultEventQueue(bridge);

                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaOrderBookFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    subscribeToBooks(symbol);
                }

                myChurnRate = options.getChurnRate();

                Thread.Sleep(10000);

                //Getting the TimerInterval from the cmd prompt
                myChurnInterval = options.getTimerInterval();

                //Churn Timer
                if (myChurnRate > 0)
                {
                    myChurnTimer = safeCreateTimer(new ChurnCallback(), myChurnInterval);
                }

                //Stats Timer
                myStatsTimer = safeCreateTimer(new StatsCallback(), 1.0);

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(bridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();

                if (myOutFile != null)
                {
                    myOut.Close();
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 27
0
 internal ListenShutdownTimerCallback(MamaBridge bridge)
 {
     m_bridge = bridge;
 }
Esempio n. 28
0
        public static void Main(string[] args)
        {
            CommandLineProcessor options      = new CommandLineProcessor(args);
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            double intervalSecs = options.getTimerInterval();

            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            try
            {
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                mySource = new MamaSource();

                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                // We might as well also enforce strict checking of order book updates
                MamdaOrderBook.setStrictChecking(true);

                /*Get the Data Dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);
                MamdaOrderBookFields.setDictionary(dictionary, null);

                if (intervalSecs == 0)
                {
                    intervalSecs = 5;
                }

                foreach (string symbol in options.getSymbolList())
                {
                    BookSelfTest          aSelfTest    = new BookSelfTest();
                    MamdaOrderBookChecker aBookChecker = new MamdaOrderBookChecker(
                        transport,
                        defaultQueue,
                        aSelfTest,
                        options.getSource(),
                        symbol,
                        intervalSecs);
                    obookCheckers.Add(aBookChecker);
                }

                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 29
0
        public static void Main(string[] args)
        {
            MamaTransport        baseTransport     = null;
            MamaTransport        optionTransport   = null;
            MamaTransport        dictTransport     = null;
            string               dictTransportName = null;
            MamaQueue            defaultQueue      = null;
            MamaDictionary       dictionary        = null;
            CommandLineProcessor options = new CommandLineProcessor(args);

            if (options.hasLogLevel())
            {
                logLevel_ = options.getLogLevel();
                Mama.enableLogging(logLevel_);
            }

            try
            {
                // Initialize MAMA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                // Initialize transports.  We're assuming that options and
                // underlyings might be on different transports.  Note:
                // some companies might use multiple transports for
                // underlyings (e.g., CTA and NASDAQ), which case it would
                // be necessary to create three transports here and be
                // sure to pass the correct transport later.
                baseTransport = new MamaTransport();
                baseTransport.create(options.getTransport(), myBridge);
                optionTransport = baseTransport;
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                // Fetch and initialize the data dictionary
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = baseTransport;
                }
                dictionarySource.transport = dictTransport;
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);
                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);
                MamdaFundamentalFields.setDictionary(dictionary, null);
                MamdaOptionFields.setDictionary(dictionary, null);

                // Create listeners for each chain.  Two subscriptions are
                // necessary.
                foreach (string symbol in options.getSymbolList())
                {
                    // Create chain and listener objects.
                    MamdaTradeListener aBaseTradeListener = new MamdaTradeListener();
                    MamdaQuoteListener aBaseQuoteListener = new MamdaQuoteListener();
                    MamdaOptionChain anOptionChain = new MamdaOptionChain(symbol);
                    anOptionChain.setUnderlyingQuoteListener(aBaseQuoteListener);
                    anOptionChain.setUnderlyingTradeListener(aBaseTradeListener);
                    MamdaOptionChainListener  anOptionListener =
                        new MamdaOptionChainListener(anOptionChain);

                    // Create our handlers (the UnderlyingTicker and
                    // OptionChainDisplay could be a single class).
                    UnderlyingTicker  aBaseTicker =
                        new UnderlyingTicker(anOptionChain, true);
                    OptionChainDisplay  aDisplay =
                        new OptionChainDisplay(anOptionChain);

                    // Create subscriptions for underlying and option chain:
                    MamdaSubscription  aBaseSubscription = new MamdaSubscription();
                    MamdaSubscription  anOptionSubscription =
                        new MamdaSubscription();

                    // Register for underlying quote and trade events.
                    aBaseTradeListener.addHandler(aBaseTicker);
                    aBaseQuoteListener.addHandler(aBaseTicker);
                    aBaseSubscription.addMsgListener(aBaseTradeListener);
                    aBaseSubscription.addMsgListener(aBaseQuoteListener);

                    aBaseSubscription.create(
                        baseTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    mamdaSubscriptions.Add(aBaseSubscription);
                    // Register for underlying option events.
                    anOptionListener.addHandler(aDisplay);

                    // We set the timeout to 1 for this example because we
                    // currently use the timeout feature to determine when
                    // to say that we have received all of the initials.
                    // There will be a separate time interval for this in
                    // the future.
                    anOptionSubscription.setTimeout(1);
                    anOptionSubscription.addMsgListener(anOptionListener);
                    anOptionSubscription.addStaleListener(aDisplay);
                    anOptionSubscription.addErrorListener(aDisplay);
                    anOptionSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP);
                    anOptionSubscription.create(
                        optionTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    optionSubscriptions.Add(anOptionSubscription);
                }

                //Start dispatching on the default event queue
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);

                Console.WriteLine("Press ENTER or Ctrl-C to quit...");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 30
0
        public static void Main(string[] args)
        {
            MamaTransport        baseTransport     = null;
            MamaTransport        optionTransport   = null;
            MamaTransport        dictTransport     = null;
            string               dictTransportName = null;
            MamaQueue            defaultQueue      = null;
            MamaDictionary       dictionary        = null;
            CommandLineProcessor options           = new CommandLineProcessor(args);


            if (options.hasLogLevel())
            {
                logLevel_ = options.getLogLevel();
                Mama.enableLogging(logLevel_);
            }

            try
            {
                // Initialize MAMA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                // Initialize transports.  We're assuming that options and
                // underlyings might be on different transports.  Note:
                // some companies might use multiple transports for
                // underlyings (e.g., CTA and NASDAQ), which case it would
                // be necessary to create three transports here and be
                // sure to pass the correct transport later.
                baseTransport = new MamaTransport();
                baseTransport.create(options.getTransport(), myBridge);
                optionTransport = baseTransport;
                defaultQueue    = Mama.getDefaultEventQueue(myBridge);

                // Fetch and initialize the data dictionary
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = baseTransport;
                }
                dictionarySource.transport = dictTransport;
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);
                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);
                MamdaFundamentalFields.setDictionary(dictionary, null);
                MamdaOptionFields.setDictionary(dictionary, null);

                // Create listeners for each chain.  Two subscriptions are
                // necessary.
                foreach (string symbol in options.getSymbolList())
                {
                    // Create chain and listener objects.
                    MamdaTradeListener aBaseTradeListener = new MamdaTradeListener();
                    MamdaQuoteListener aBaseQuoteListener = new MamdaQuoteListener();
                    MamdaOptionChain   anOptionChain      = new MamdaOptionChain(symbol);
                    anOptionChain.setUnderlyingQuoteListener(aBaseQuoteListener);
                    anOptionChain.setUnderlyingTradeListener(aBaseTradeListener);
                    MamdaOptionChainListener anOptionListener =
                        new MamdaOptionChainListener(anOptionChain);

                    // Create our handlers (the UnderlyingTicker and
                    // OptionChainDisplay could be a single class).
                    UnderlyingTicker aBaseTicker =
                        new UnderlyingTicker(anOptionChain, true);
                    OptionChainDisplay aDisplay =
                        new OptionChainDisplay(anOptionChain);

                    // Create subscriptions for underlying and option chain:
                    MamdaSubscription aBaseSubscription    = new MamdaSubscription();
                    MamdaSubscription anOptionSubscription =
                        new MamdaSubscription();

                    // Register for underlying quote and trade events.
                    aBaseTradeListener.addHandler(aBaseTicker);
                    aBaseQuoteListener.addHandler(aBaseTicker);
                    aBaseSubscription.addMsgListener(aBaseTradeListener);
                    aBaseSubscription.addMsgListener(aBaseQuoteListener);

                    aBaseSubscription.create(
                        baseTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    mamdaSubscriptions.Add(aBaseSubscription);
                    // Register for underlying option events.
                    anOptionListener.addHandler(aDisplay);

                    // We set the timeout to 1 for this example because we
                    // currently use the timeout feature to determine when
                    // to say that we have received all of the initials.
                    // There will be a separate time interval for this in
                    // the future.
                    anOptionSubscription.setTimeout(1);
                    anOptionSubscription.addMsgListener(anOptionListener);
                    anOptionSubscription.addStaleListener(aDisplay);
                    anOptionSubscription.addErrorListener(aDisplay);
                    anOptionSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP);
                    anOptionSubscription.create(
                        optionTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    optionSubscriptions.Add(anOptionSubscription);
                }

                //Start dispatching on the default event queue
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);

                Console.WriteLine("Press ENTER or Ctrl-C to quit...");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 31
0
        public static void Main(string[] args)
        {
            CommandLineProcessor options      = new CommandLineProcessor(args);
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            double               intervalSecs = options.getTimerInterval();
            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            try
            {
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                mySource = new MamaSource();

                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                // We might as well also enforce strict checking of order book updates
                MamdaOrderBook.setStrictChecking(true);

                /*Get the Data Dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);
                MamdaOrderBookFields.setDictionary(dictionary, null);

                if (intervalSecs == 0)
                {
                    intervalSecs = 5;
                }

                foreach (string symbol in options.getSymbolList())
                {
                    BookSelfTest aSelfTest             = new BookSelfTest ();
                    MamdaOrderBookChecker aBookChecker = new MamdaOrderBookChecker(
                        transport,
                        defaultQueue,
                        aSelfTest,
                        options.getSource(),
                        symbol,
                        intervalSecs);
                    obookCheckers.Add(aBookChecker);

                }

                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Environment.Exit(1);
            }
        }
Esempio n. 32
0
        static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor (args);
            myQuietModeLevel = options.getQuietModeLevel();

            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            myCacheFullBooks = options.cacheFullBooks();
            myPrintEntries = options.getPrintEntries();
            mySnapshot = options.getSnapshot();
            myPrecision = options.getPrecision();
            try
            {
                //Initialize MAMA API
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                myMamaSource = new MamaSource ();
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaOrderBookFields.setDictionary (dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription();
                    MamdaOrderBookListener aBookListener;
                    if (myCacheFullBooks)
                    {
                        aBookListener = new MamdaOrderBookListener();
                    }
                    else
                    {
                        aBookListener = new MamdaOrderBookListener(null, new MamdaOrderBook());
                    }

                    BookTicker aTicker = new BookTicker();

                    aBookListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aBookListener);
                    aSubscription.addStaleListener(aTicker);
                    aSubscription.addErrorListener(aTicker);

                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);
                    if (mySnapshot)
                    {
                        aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0);
                    }
                    aSubscription.create(
                        transport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);

                    mamdaSubscriptions.Add(aSubscription);
                }

                //Start dispatching on the default MAMA event queue
                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }