public int Run()
        {
            ParseArgs();
            if (helpNeeded)
            {
                DisplayUsage();
                return(0);
            }

            Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_FINEST);
            bridge = Mama.loadBridge(middlewareName);
            Mama.open();
            MamaTransport    transport    = new MamaTransport();
            MamaQueue        defaultQueue = Mama.getDefaultEventQueue(bridge);
            MamaTimer        timer        = new MamaTimer();
            MamaSubscription subscription = new MamaSubscription();
            MamaPublisherCS  publisher    = this;

            transport.create(transportName, bridge);
            timer.create(defaultQueue, publisher, interval, null);
            subscription.createBasic(transport, defaultQueue, publisher, inboundTopic);
            publisher.create(transport, outboundTopic);
            msg = new MamaMsg();

            Mama.start(bridge);
            Mama.close();
            return(0);
        }
Esempio n. 2
0
        public int Run()
        {
            ParseArgs();
            if (helpNeeded)
            {
                DisplayUsage();
                return(0);
            }

            Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_NORMAL);

            bridge = Mama.loadBridge(middlewareName);

            Mama.open();

            MamaQueue defaultQueue = Mama.getDefaultEventQueue(bridge);

            msg = new MamaMsg();

            MamaTimer timer = new MamaTimer();

            timer.create(defaultQueue, this, interval, null);

            queueGroup = new MamaQueueGroup(bridge, 1);

            MamaTransport transport = new MamaTransport();

            transport.create(transportName, bridge);

            MamaSubscription subscription = null;

            if (nosub == false)
            {
                subscription = new MamaSubscription();
                subscription.createBasic(transport, defaultQueue, this, inboundTopic);
            }

            publisher = new MamaPublisher();
            if (pubCb)
            {
                publisher.createWithCallbacks(transport, queueGroup.getNextQueue(), this, null, outboundTopic, null, null);
            }
            else
            {
                publisher.create(transport, outboundTopic);
            }

            Mama.start(bridge);

            Mama.close();

            return(0);
        }
Esempio n. 3
0
        private MamaChurnCS(string[] args)
        {
            try
            {
                if (parseCommandLine(args))
                {

                    // Start up the underlying API
                    initializeMama();
                    try
                    {
                        // Create all of the subscriptions
                        createSubscriptions();
                        try
                        {
                            // Create the autoreset event that will be used to shutdown
                            m_killEvent = new ManualResetEvent(false);

                            // Create a spearate thread to perform the churn
                            m_churnThread = new Thread(new ThreadStart(this.ChurnThreadProc));
                            m_churnThread.IsBackground = true;
                            m_churnThread.Name = "destroyerThread: ";
                            m_churnThread.Start();

                            stats = new StatsReport(mamaDefaultQueue);

                            // If the timeout has been supplied then create a new timer
                            if (m_killTimeout > 0)
                            {
                                MamaTimer killTimer = new MamaTimer();
                                killTimer.create(Mama.getDefaultEventQueue(mamaBridge), new KillTimerCallback(mamaBridge), m_killTimeout, null);
                            }

                            // Keep procssing messages until the kill timer elapses
                            Mama.start(mamaBridge);

                            // Destroy the stats timer
                            stats.destroy();

                            // Kill the churn thread by signaling the auto reset event
                            m_killEvent.Set();

                            // Wait until the thread terminates
                            m_churnThread.Join();
                        }

                        finally
                        {
                            // Stop processing all the queues
                            mamaQueueGroup.stop();

                            // Destroy all the subscriptions                            
                            for (int subIndex = 0; subIndex < mamaSubscriptions.Length; subIndex++)
                            {
                                mamaSubscriptions[subIndex].destroy();
                                mamaSubscriptions[subIndex] = null;
                            }
                        }
                    }

                    finally
                    {
                        // Uninitialise the api
                        unintializeMama();
                    }
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This is the thread procedure that is executed by the churn thread, it will keep
        /// churning subscriptions until the kill event is set.
        /// </summary>
        private void ChurnThreadProc()
        {

            for (; ; )
            {
                // Check the for kill event
                bool signal = m_killEvent.WaitOne(1000, false);

                // Quit the loop if the kill signal was received
                if (signal)
                {
                    break;
                }

                // Churn subscriptions
                for (int j = 0; j < quota; j++)
                {
                    int i = mamaRandom.Next(0, mamaNumSymbols);

                    MamaTimer timer = new MamaTimer();

                    // Get the queue
                    MamaQueue queue = mamaSubscriptions[i].subscQueue;
                    if (queue != null)
                    {
                        timer.create(queue, this, m_churnTimeout, i);
                    }
                }
            }
        }
Esempio n. 5
0
            public StatsReport(MamaQueue mamaDefaultQueue)
            {
                statstimer = new MamaTimer();

                statstimer.create(mamaDefaultQueue, this, 2, null);

                Console.WriteLine("    Time" + " {0, -4} {1, -4} {2, -4} {3, -4} {4, -2}",
                    "Create", "Inital", "OtherMsg", "Error", "Recreate");
            }
Esempio n. 6
0
        public int Run()
        {
            ParseArgs();
            if (helpNeeded)
            {
                DisplayUsage();
                return 0;
            }

            Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_NORMAL);

            bridge = Mama.loadBridge(middlewareName);

            Mama.open();

            MamaQueue defaultQueue = Mama.getDefaultEventQueue(bridge);
            msg = new MamaMsg();

            MamaTimer timer = new MamaTimer();
            timer.create(defaultQueue, this, interval, null);

            queueGroup = new MamaQueueGroup(bridge, 1);

            MamaTransport transport = new MamaTransport();
            transport.create(transportName, bridge);

            MamaSubscription subscription = null;
            if (nosub == false)
            {
                subscription = new MamaSubscription();
                subscription.createBasic(transport, defaultQueue, this, inboundTopic);
            }

            publisher = new MamaPublisher();
            if (pubCb)
            {
                publisher.createWithCallbacks(transport, queueGroup.getNextQueue(), this, null, outboundTopic, null, null);
            }
            else
            {
                publisher.create(transport, outboundTopic);
            }

            Mama.start(bridge);

            Mama.close();

            return 0;
        }
Esempio n. 7
0
        /// <summary>
        /// This function will run the application and create market data subscriptions.
        /// </summary>
        /// <param name="args">
        /// Command line arguments.
        /// </param>            
        internal void run(string[] args)
        {
            // Install an event handler to capture the Ctrl-C press
            NativeMethods.ControlEventHandler eventHandler = new NativeMethods.ControlEventHandler(this.onControlHandler);
            NativeMethods.SetConsoleCtrlHandler(eventHandler, true);

            // Parse the command line arguments
            bool shouldContinue = parseCommandLine(args);
            if (shouldContinue)
            {
                initializeMama();
                try
                {
                    createSubscriptions();
                    try
                    {
                        // Create a shutdown timer if appropriate
                        if (m_shutdownTime > 0)
                        {
                            // The timer will be destroyed whenever it ticks
                            MamaTimer shutdownTimer = new MamaTimer();
                            shutdownTimer.create(m_defaultQueue, new ListenShutdownTimerCallback(m_bridge), m_shutdownTime, null);
                        }

                        // Start the bridge, this call will block until either Ctrl C is pressed or the shutdown timer ticks
                        Mama.start(m_bridge);
                    }

                    finally
                    {
                        destroySubscriptions();
                    }
                }
                finally
                {
                    // Clean up mama
                    uninitializeMama();
                }
            }
        }
Esempio n. 8
0
        public int Run()
        {
            ParseArgs();
            if (helpNeeded)
            {
                DisplayUsage();
                return 0;
            }

            Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_FINEST);
            bridge = Mama.loadBridge(middlewareName);
            Mama.open();
            MamaTransport transport = new MamaTransport();
            MamaQueue defaultQueue = Mama.getDefaultEventQueue(bridge);
            MamaTimer timer = new MamaTimer();
            MamaSubscription subscription = new MamaSubscription();
            MamaPublisherCS publisher = this;

            transport.create(transportName, bridge);
            timer.create(defaultQueue, publisher, interval, null);
            subscription.createBasic(transport, defaultQueue, publisher, inboundTopic);
            publisher.create(transport, outboundTopic);
            msg = new MamaMsg();

            Mama.start(bridge);
            Mama.close();
            return 0;
        }