protected override void DisposeManagedResources()
 {
     _consumerChannelReply?.Dispose();
     ConsumerChannel?.Dispose();
     SubsManager?.Clear();
     SubsManager?.ClearReply();
 }
Esempio n. 2
0
 public void Dispose()
 {
     ConsumerChannel?.Dispose();
     ConsumerChannel = null;
     if (_timer == null)
     {
         return;
     }
     _timer.Dispose();
     _timer = null;
 }
        protected override IModel CreateConsumerChannel(CancellationToken cancel = default)
        {
            if (!PersistentConnection.IsConnected)
            {
                PersistentConnection.TryConnect();
            }

            var channel = PersistentConnection.CreateModel();

            channel.ExchangeDeclare(ExchangeDeclareParameters.ExchangeName, ExchangeDeclareParameters.ExchangeType, ExchangeDeclareParameters.ExchangeDurable, ExchangeDeclareParameters.ExchangeAutoDelete);

            channel.QueueDeclare(QueueName, QueueDeclareParameters.QueueDurable, QueueDeclareParameters.QueueExclusive, QueueDeclareParameters.QueueAutoDelete, null);
            channel.BasicQos(0, 1, false);

            channel.CallbackException += (sender, ea) =>
            {
                Logger.LogError("CallbackException: " + ea.Exception.Message);
                ConsumerChannel.Dispose();
                ConsumerChannel = CreateConsumerChannel(cancel);
                StartBasicConsume();
            };

            return(channel);
        }