Exemplo n.º 1
0
        public void TestQueueService_UnbindQueue()
        {
            // Create exchanges
            TestQueueService_DeclareQueue_ValidExchange();

            // Data
            QueueBindingModel qu = new QueueBindingModel()
            {
                Source      = "amq.direct",
                Destination = "company.queues.finance2"
            };

            // Assert
            Assert.DoesNotThrow(() => { BaseQueueService.Unbind(qu); });
        }
 /// <summary>
 /// Unbinds a single queue from it's exchange
 /// </summary>
 /// <param name="binding"></param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ServiceException"></exception>
 /// <exception cref="ValidationException"></exception>
 public void Unbind(QueueBindingModel binding)
 {
     try
     {
         Validate(binding, "Queue to unbind cannot be null");
         Channel.QueueUnbind(binding.Destination, binding.Source, binding.RoutingKey, binding.Arguments);
     }
     catch (Exception ex) when(ex is ArgumentNullException || ex is ServiceException || ex is ValidationException)
     {
         throw;
     }
     catch (OperationInterruptedException ex)
     {
         Logger.Warn(ex.Message);
         throw new ServiceException("Queue Service Exception: Exchange or queue does not exist is the likely cause, please see log for more details.");
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
         throw new ServiceException("Queue Service Exception: please see log for more details.");
     }
 }