Esempio n. 1
0
        public void Close(ushort replyCode, string replyText, bool abort)
        {
            ShutdownContinuation k = new ShutdownContinuation();

            ModelShutdown += new ModelShutdownEventHandler(k.OnShutdown);

            try {
                if (SetCloseReason(new ShutdownEventArgs(ShutdownInitiator.Application,
                                                         replyCode,
                                                         replyText)))
                {
                    _Private_ChannelClose(replyCode, replyText, 0, 0);
                }
                k.Wait();
            } catch (AlreadyClosedException ace) {
                if (!abort)
                {
                    throw ace;
                }
            } catch (IOException ioe) {
                if (!abort)
                {
                    throw ioe;
                }
            }
        }
Esempio n. 2
0
        public string BasicConsume(string queue,
                                   bool noAck,
                                   string consumerTag,
                                   bool noLocal,
                                   bool exclusive,
                                   IDictionary filter,
                                   IBasicConsumer consumer)
        {
            ModelShutdown += new ModelShutdownEventHandler(consumer.HandleModelShutdown);

            BasicConsumerRpcContinuation k = new BasicConsumerRpcContinuation();

            k.m_consumer = consumer;

            Enqueue(k);
            // Non-nowait. We have an unconventional means of getting
            // the RPC response, but a response is still expected.
            try
            {
                _Private_BasicConsume(queue, consumerTag, noLocal, noAck, exclusive,
                                      /*nowait:*/ false, filter);
            }
            catch (AlreadyClosedException)
            {
                // Ignored, since the continuation will be told about
                // the closure via an OperationInterruptedException because
                // of the shutdown event propagation.
            }
            k.GetReply();
            string actualConsumerTag = k.m_consumerTag;

            return(actualConsumerTag);
        }
Esempio n. 3
0
        ///<summary>Broadcasts notification of the final shutdown of the model.</summary>
        ///<remarks>
        ///<para>
        ///Do not call anywhere other than at the end of OnSessionShutdown.
        ///</para>
        ///<para>
        ///Must not be called when m_closeReason == null, because
        ///otherwise there's a window when a new continuation could be
        ///being enqueued at the same time as we're broadcasting the
        ///shutdown event. See the definition of Enqueue() above.
        ///</para>
        ///</remarks>
        public virtual void OnModelShutdown(ShutdownEventArgs reason)
        {
            //Console.WriteLine("Model shutdown "+((Session)m_session).ChannelNumber+": "+reason);
            m_continuationQueue.HandleModelShutdown(reason);
            ModelShutdownEventHandler handler;

            lock (m_shutdownLock)
            {
                handler         = m_modelShutdown;
                m_modelShutdown = null;
            }
            if (handler != null)
            {
                foreach (ModelShutdownEventHandler h in handler.GetInvocationList())
                {
                    try {
                        h(this, reason);
                    } catch (Exception e) {
                        CallbackExceptionEventArgs args = new CallbackExceptionEventArgs(e);
                        args.Detail["context"] = "OnModelShutdown";
                        OnCallbackException(args);
                    }
                }
            }
            m_flowControlBlock.Set();
        }
Esempio n. 4
0
        public void BasicCancel(string consumerTag)
        {
            BasicConsumerRpcContinuation k = new BasicConsumerRpcContinuation();

            k.m_consumerTag = consumerTag;

            Enqueue(k);

            try
            {
                _Private_BasicCancel(consumerTag, false);
            }
            catch (AlreadyClosedException)
            {
                // Ignored, since the continuation will be told about
                // the closure via an OperationInterruptedException because
                // of the shutdown event propagation.
            }

            k.GetReply();

            ModelShutdown -= new ModelShutdownEventHandler(k.m_consumer.HandleModelShutdown);
        }
 ///<summary>Broadcasts notification of the final shutdown of the model.</summary>
 ///<remarks>
 ///<para>
 ///Do not call anywhere other than at the end of OnSessionShutdown.
 ///</para>
 ///<para>
 ///Must not be called when m_closeReason == null, because
 ///otherwise there's a window when a new continuation could be
 ///being enqueued at the same time as we're broadcasting the
 ///shutdown event. See the definition of Enqueue() above.
 ///</para>
 ///</remarks>
 public virtual void OnModelShutdown(ShutdownEventArgs reason)
 {
     //Console.WriteLine("Model shutdown "+((Session)m_session).ChannelNumber+": "+reason);
     m_continuationQueue.HandleModelShutdown(reason);
     ModelShutdownEventHandler handler;
     lock (m_shutdownLock)
     {
         handler = m_modelShutdown;
         m_modelShutdown = null;
     }
     if (handler != null)
     {
         foreach (ModelShutdownEventHandler h in handler.GetInvocationList()) {
             try {
                 h(this, reason);
             } catch (Exception e) {
                 CallbackExceptionEventArgs args = new CallbackExceptionEventArgs(e);
                 args.Detail["context"] = "OnModelShutdown";
                 OnCallbackException(args);
             }
         }
     }
     lock (m_unconfirmedSet.SyncRoot)
         Monitor.Pulse(m_unconfirmedSet.SyncRoot);
     m_flowControlBlock.Set();
 }
        public void Close(ShutdownEventArgs reason, bool abort)
        {
            ShutdownContinuation k = new ShutdownContinuation();
            ModelShutdown += new ModelShutdownEventHandler(k.OnShutdown);

            try {
                if (SetCloseReason(reason))
                {
                    _Private_ChannelClose(reason.ReplyCode, reason.ReplyText, 0, 0);
                }
                k.Wait();
            } catch (AlreadyClosedException ace) {
                if (!abort)
                    throw ace;
            } catch (IOException ioe) {
                if (!abort)
                    throw ioe;
            }
        }
        public void BasicCancel(string consumerTag)
        {
            BasicConsumerRpcContinuation k = new BasicConsumerRpcContinuation();
            k.m_consumerTag = consumerTag;

            Enqueue(k);

            _Private_BasicCancel(consumerTag, false);
            k.GetReply();

            ModelShutdown -= new ModelShutdownEventHandler(k.m_consumer.HandleModelShutdown);
        }
        public string BasicConsume(string queue,
                                   bool noAck,
                                   string consumerTag,
                                   bool noLocal,
                                   bool exclusive,
                                   IDictionary<string, object> arguments,
                                   IBasicConsumer consumer)
        {
            ModelShutdown += new ModelShutdownEventHandler(consumer.HandleModelShutdown);

            BasicConsumerRpcContinuation k = new BasicConsumerRpcContinuation();
            k.m_consumer = consumer;

            Enqueue(k);
            // Non-nowait. We have an unconventional means of getting
            // the RPC response, but a response is still expected.
            _Private_BasicConsume(queue, consumerTag, noLocal, noAck, exclusive,
                                  /*nowait:*/ false, arguments);
            k.GetReply();
            string actualConsumerTag = k.m_consumerTag;

            return actualConsumerTag;
        }
Esempio n. 9
0
 /// <summary>The remove shutdown listener.</summary>
 /// <param name="listener">The listener.</param>
 public void RemoveShutdownListener(ModelShutdownEventHandler listener)
 {
     this.channelDelegate.ModelShutdown -= listener;
 }
Esempio n. 10
0
 /// <summary>The add shutdown listener.</summary>
 /// <param name="listener">The listener.</param>
 public void AddShutdownListener(ModelShutdownEventHandler listener)
 {
     this.channelDelegate.ModelShutdown += listener;
 }
        public string BasicConsume(string queue,
                                   bool noAck,
                                   string consumerTag,
                                   bool noLocal,
                                   bool exclusive,
                                   IDictionary<string, object> arguments,
                                   IBasicConsumer consumer)
        {
            ModelShutdown += new ModelShutdownEventHandler(consumer.HandleModelShutdown);

            BasicConsumerRpcContinuation k = new BasicConsumerRpcContinuation();
            k.m_consumer = consumer;

            Enqueue(k);
            // Non-nowait. We have an unconventional means of getting
            // the RPC response, but a response is still expected.
            try
            {
                _Private_BasicConsume(queue, consumerTag, noLocal, noAck, exclusive,
                    /*nowait:*/ false, arguments);
            }
            catch (AlreadyClosedException)
            {
                // Ignored, since the continuation will be told about
                // the closure via an OperationInterruptedException because
                // of the shutdown event propagation.
            }
            k.GetReply();
            string actualConsumerTag = k.m_consumerTag;

            return actualConsumerTag;
        }
        public void BasicCancel(string consumerTag)
        {
            BasicConsumerRpcContinuation k = new BasicConsumerRpcContinuation();
            k.m_consumerTag = consumerTag;

            Enqueue(k);

            try
            {
                _Private_BasicCancel(consumerTag, false);
            }
            catch (AlreadyClosedException)
            {
                // Ignored, since the continuation will be told about
                // the closure via an OperationInterruptedException because
                // of the shutdown event propagation.
            }

            k.GetReply();

            ModelShutdown -= new ModelShutdownEventHandler(k.m_consumer.HandleModelShutdown);
        }
 /// <summary>The remove shutdown listener.</summary>
 /// <param name="listener">The listener.</param>
 public void RemoveShutdownListener(ModelShutdownEventHandler listener) { this.channelDelegate.ModelShutdown -= listener; }
 /// <summary>The add shutdown listener.</summary>
 /// <param name="listener">The listener.</param>
 public void AddShutdownListener(ModelShutdownEventHandler listener) { this.channelDelegate.ModelShutdown += listener; }