public void QueueDelete(RabbitMQQueueDeclaration declaration)
 {
     lock (@lock)
     {
         try
         {
             if (declaration.NoWait)
             {
                 channel.QueueDeleteNoWait(
                     declaration.Name,
                     declaration.UnusedOnly,
                     declaration.EmptyOnly);
             }
             else
             {
                 channel.QueueDelete(
                     declaration.Name,
                     declaration.UnusedOnly,
                     declaration.EmptyOnly);
             }
         }
         catch (OperationInterruptedException) when(declaration.UnusedOnly || declaration.EmptyOnly)
         {
             // RabbitMQ.Client does not ignore PRECONDITION_FAILED
             // Means that queue is used or not empty, so just ignore exception
             // TODO: Informative logging
             logger.LogWarning($"Unable to delete '{declaration.Name}' queue");
         }
     }
 }
 public void QueueUnbind(RabbitMQQueueDeclaration declaration, RabbitMQQueueBindingDeclaration binding)
 {
     lock (@lock)
     {
         channel.QueueUnbind(
             declaration.Name,
             binding.ExchangeDeclaration.Name,
             binding.RoutingKey ?? declaration.Name,
             binding.Arguments);
     }
 }
        public static IRabbitMQQueueBuilder <TPayload> AddQueue <TPayload>(
            this IRabbitMQConnectionBuilder connection,
            string queueName)
        {
            var declaration = new RabbitMQQueueDeclaration(connection.ConnectionDeclaration, queueName);

            connection.Services
            .Configure <RabbitMQOptions>(
                options => options.QueueDeclarations.Add(declaration));

            return(new RabbitMQQueueBuilder <TPayload>(declaration));
        }
 // Consumers
 public void BasicConsume(
     IServiceProvider serviceProvider,
     RabbitMQOptions options,
     RabbitMQQueueDeclaration queue,
     RabbitMQConsumerDeclaration declaration,
     CancellationToken cancellationToken)
 {
     lock (@lock)
     {
         for (var index = 0; index < declaration.Count; index++)
         {
             channel.BasicConsume(
                 queue: queue.Name,
                 autoAck: declaration.AutoAck,
                 consumerTag: declaration.Tag is null
                                                 ? string.Empty
                                                 : $"{declaration.Tag}_{index}",
                 noLocal: declaration.NoLocal,
                 exclusive: declaration.Exclusive,
                 arguments: declaration.Arguments,
                 consumer: new RabbitMQConsumer(channel, options, serviceProvider, declaration, cancellationToken));
         }
     }
 }
 // Queues
 public void QueueDeclare(RabbitMQQueueDeclaration declaration)
 {
     lock (@lock)
     {
         if (declaration.NoWait)
         {
             channel.QueueDeclareNoWait(
                 queue: declaration.Name,
                 durable: declaration.Durable,
                 exclusive: declaration.Exclusive,
                 autoDelete: declaration.AutoDelete,
                 arguments: declaration.Arguments);
         }
         else
         {
             channel.QueueDeclare(
                 queue: declaration.Name,
                 durable: declaration.Durable,
                 exclusive: declaration.Exclusive,
                 autoDelete: declaration.AutoDelete,
                 arguments: declaration.Arguments);
         }
     }
 }