Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        private static void subscribeToBooks(string symbol)
        {
            MamdaSubscription aSubscription      = new MamdaSubscription();
            MamdaOrderBookListener aBookListener = new MamdaOrderBookListener();
            ListenerCallback callback            = new ListenerCallback();

            aBookListener.addHandler(callback);
            aSubscription.addMsgListener(aBookListener);
            aSubscription.addStaleListener(callback);
            aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);

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

            //Add the Mamda Subscription to the ArrayList
            subscriptionList.Add(aSubscription);
        }
Exemplo n.º 4
0
 public void Enqueue(ListenerCallback cb)
 {
     queue.Enqueue(cb);
 }