Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
            public void onSecurityCreate(
				MamdaSubscription           subscription,
				MamdaMultiSecurityManager   manager,
				string                      symbol)
            {
                MamdaTradeListener aTradeListener = new MamdaTradeListener();
                MamdaQuoteListener aQuoteListener = new MamdaQuoteListener();
                ComboTicker        aTicker        = new ComboTicker();

                aTradeListener.addHandler(aTicker);
                aQuoteListener.addHandler(aTicker);

                manager.addListener(aTradeListener, symbol);
                manager.addListener(aQuoteListener, symbol);
            }