public void ExchangeBind(
            RabbitMQExchangeDeclaration declaration,
            RabbitMQExchangeBindingDeclaration binding)
        {
            var routingKey = binding.RoutingKey ?? declaration.Name;

            lock (@lock)
            {
                if (binding.NoWait)
                {
                    channel.ExchangeBindNoWait(
                        destination: declaration.Name,
                        source: binding.ExchangeDeclaration.Name,
                        routingKey: routingKey,
                        arguments: binding.Arguments);
                }
                else
                {
                    channel.ExchangeBind(
                        destination: declaration.Name,
                        source: binding.ExchangeDeclaration.Name,
                        routingKey: routingKey,
                        arguments: binding.Arguments);
                }
            }
        }
示例#2
0
 public RabbitMQProducerDeclaration(
     Type payloadType,
     RabbitMQConnectionDeclaration connectionDeclaration,
     RabbitMQExchangeDeclaration exchangeDeclaration)
 {
     PayloadType           = payloadType;
     ConnectionDeclaration = connectionDeclaration;
     ExchangeDeclaration   = exchangeDeclaration;
     Properties            = new List <Action <IBasicProperties> >();
     Arguments             = new Dictionary <string, object>();
 }
        public static IRabbitMQExchangeBuilder AddExchange(
            this IRabbitMQConnectionBuilder connection,
            string type,
            string name)
        {
            var declaration = new RabbitMQExchangeDeclaration(connection.ConnectionDeclaration, type, name);

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

            return(new RabbitMQExchangeBuilder(declaration));
        }
 public void ExchangeDelete(RabbitMQExchangeDeclaration declaration)
 {
     lock (@lock)
     {
         // TODO: try-catch when unused only failed?
         if (declaration.NoWait)
         {
             channel.ExchangeDeleteNoWait(
                 declaration.Name,
                 declaration.UnusedOnly);
         }
         else
         {
             channel.ExchangeDelete(
                 declaration.Name,
                 declaration.UnusedOnly);
         }
     }
 }
 // Exchanges
 public void ExchangeDeclare(RabbitMQExchangeDeclaration declaration)
 {
     lock (@lock)
     {
         if (declaration.Internal)
         {
             channel._Private_ExchangeDeclare(
                 exchange: declaration.Name,
                 type: declaration.Type,
                 passive: false,
                 durable: declaration.Durable,
                 autoDelete: declaration.AutoDelete,
                 @internal: declaration.Internal,
                 nowait: declaration.NoWait,
                 arguments: declaration.Arguments);
         }
         else
         {
             if (declaration.NoWait)
             {
                 channel.ExchangeDeclareNoWait(
                     exchange: declaration.Name,
                     type: declaration.Type,
                     durable: declaration.Durable,
                     autoDelete: declaration.AutoDelete,
                     arguments: declaration.Arguments);
             }
             else
             {
                 channel.ExchangeDeclare(
                     exchange: declaration.Name,
                     type: declaration.Type,
                     durable: declaration.Durable,
                     autoDelete: declaration.AutoDelete,
                     arguments: declaration.Arguments);
             }
         }
     }
 }
示例#6
0
		public RabbitMQExchangeBindingDeclaration(RabbitMQExchangeDeclaration exchangeDeclaration)
		{
			ExchangeDeclaration = exchangeDeclaration;
			Arguments = new Dictionary<string, object>();
		}