Example #1
0
        public void Stop()
        {
            if (started.CompareAndSet(true, false))
            {
                try
                {
                    lock (producers.SyncRoot)
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.Stop();
                        }
                    }
                    lock (consumers.SyncRoot)
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.Stop();
                        }
                    }

                    qpidSession.Dispose();
                    qpidSession = null;
                }
                catch (Org.Apache.Qpid.Messaging.QpidException e)
                {
                    throw new NMSException("Failed to close session with Id " + SessionId.ToString() + " : " + e.Message);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Create new unmanaged session and start senders and receivers
        /// Associated connection must be open.
        /// </summary>
        public void Start()
        {
            // Don't try creating session if connection not yet up
            if (!connection.IsStarted)
            {
                throw new ConnectionClosedException();
            }

            if (started.CompareAndSet(false, true))
            {
                try
                {
                    // Create qpid session
                    if (qpidSession == null)
                    {
                        qpidSession = connection.CreateQpidSession();
                    }

                    // Start producers and consumers
                    lock (producers.SyncRoot)
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.Start();
                        }
                    }
                    lock (consumers.SyncRoot)
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.Start();
                        }
                    }
                }
                catch (Org.Apache.Qpid.Messaging.QpidException e)
                {
                    throw new SessionClosedException("Failed to create session : " + e.Message);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Create new unmanaged session and start senders and receivers
        /// Associated connection must be open.
        /// </summary>
        public void Start()
        {
            // Don't try creating session if connection not yet up
            if (!connection.IsStarted)
            {
                throw new ConnectionClosedException();
            }

            if (started.CompareAndSet(false, true))
            {
                try
                {
                    // Create qpid session
                    if (qpidSession == null)
                    {
                        qpidSession = connection.CreateQpidSession();
                    }

                    // Start producers and consumers
                    lock (producers.SyncRoot)
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.Start();
                        }
                    }
                    lock (consumers.SyncRoot)
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.Start();
                        }
                    }
                }
                catch (Org.Apache.Qpid.Messaging.QpidException e)
                {
                    throw new SessionClosedException( "Failed to create session : " + e.Message );
                }
            }
        }
Example #4
0
        public void Stop()
        {
            if (started.CompareAndSet(true, false))
            {
                try
                {
                    lock (producers.SyncRoot)
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.Stop();
                        }
                    }
                    lock (consumers.SyncRoot)
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.Stop();
                        }
                    }

                    qpidSession.Dispose();
                    qpidSession = null;
                }
                catch (Org.Apache.Qpid.Messaging.QpidException e)
                {
                    throw new NMSException("Failed to close session with Id " + SessionId.ToString() + " : " + e.Message);
                }
            }
        }