Ejemplo n.º 1
0
        /// <summary>
        /// Opens this instance.
        /// </summary>
        public override void Open()
        {
            try
            {
                if (IsOpen() && _queueingConsumer != null)
                {
                    return;
                }

                base.Open();

                try
                {
                    _queueingConsumer = new RMQBasicConsumer(_channel);

                    _channel.BasicConsume(_queueSettings.QueueName,
                                          _queueSettings.ConsumerSettings.NoAck,
                                          _queueSettings.ConsumerSettings.Tag,
                                          _queueSettings.ConsumerSettings.NoLocal,
                                          _queueSettings.ConsumerSettings.Exclusive,
                                          _queueSettings.ConsumerSettings.Arguments,
                                          _queueingConsumer);

                    _queueingConsumer.ConsumerCancelled += OnCancelConsumer;
                }
                catch (Exception)
                {
                    _queueingConsumer = null;
                    throw;
                }
            }
            catch (Exception ex)
            {
                var newException = RMQExceptionHandler.ExceptionHandler(_connection, ex);
                if (newException != null)
                {
                    throw newException;
                }

                throw;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Called when [cancel consumer].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="ConsumerEventArgs"/> instance containing the event data.</param>
 private void OnCancelConsumer(object sender, ConsumerEventArgs args)
 {
     _queueingConsumer = null;
 }