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. 2
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. 3
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);
            }
        }
        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);
            }
        }