Exemple #1
0
        private void createQueues()
        {
            mamaDefaultQueue = Mama.getDefaultEventQueue(mamaBridge);

            mamaQueueGroup = new MamaQueueGroup(mamaBridge, mamaThreads);

            if (mamaThreads > 0)
            {
                // Has queue monitoring been enabled?
                if (mamaHighWaterMark > 0 || mamaLowWaterMark > 0)
                {
                    for (int index = 0; index < mamaThreads; index++)
                    {
                        MamaQueue queue     = mamaQueueGroup.getNextQueue();
                        string    queueName = "QUEUE " + index;
                        Console.WriteLine("Setting monitor for " + queueName);
                        queue.setQueueMonitorCallbacks(this, queueName);
                        if (mamaHighWaterMark > 0)
                        {
                            queue.setHighWatermark(mamaHighWaterMark);
                        }

                        if (mamaLowWaterMark > 0)
                        {
                            try
                            {
                                // Not supported on all middlewares.
                                queue.setLowWatermark(mamaLowWaterMark);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("Could not set " + queueName + " queue low water mark MamaStatus: " + e);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Queues will be created if the user has specified a number of threads to be
        /// used, otherwise the default queue will be used.
        /// </summary>
        private void createQueues()
        {
            // Only continue if the number of threads required is greater than 0
            if (m_numberThreads > 0)
            {
                m_queueGroup = new MamaQueueGroup(m_bridge, m_numberThreads);

                if ((m_highWaterMark > 0) || (m_lowWaterMark > 0))
                {
                    ListenerQueueCallback queueCallback = new ListenerQueueCallback();

                    // Install the callback on each queue
                    for (int index = 0; index < m_numberThreads; index++)
                    {
                        MamaQueue queue = m_queueGroup.getNextQueue();

                        string queueName = ("QUEUE " + index);
                        Console.WriteLine("Setting monitor for " + queueName);

                        // Install the callbacks
                        queue.setQueueMonitorCallbacks(queueCallback, queueName);

                        // Set the watermarks at which the callbacks are invoked
                        if (m_highWaterMark > 0)
                        {
                            queue.setHighWatermark(m_highWaterMark);
                        }

                        if (m_lowWaterMark > 0)
                        {
                            // Not supported on all middlewares.
                            queue.setLowWatermark(m_lowWaterMark);
                        }
                    }
                }
            }
        }