示例#1
0
        private void DeclareBindings(RC.IModel channel, params IBinding[] bindings)
        {
            foreach (var binding in bindings)
            {
                _logger?.LogDebug("Binding destination [{destination} ({type})] to exchange [{exchange}] with routing key [{routingKey}]", binding.Destination, binding.Type, binding.Exchange, binding.RoutingKey);

                try
                {
                    if (binding.IsDestinationQueue)
                    {
                        if (!IsDeclaringImplicitQueueBinding(binding))
                        {
                            channel.QueueBind(binding.Destination, binding.Exchange, binding.RoutingKey, binding.Arguments);
                        }
                    }
                    else
                    {
                        channel.ExchangeBind(binding.Destination, binding.Exchange, binding.RoutingKey, binding.Arguments);
                    }
                }
                catch (Exception e)
                {
                    LogOrRethrowDeclarationException(binding, "binding", e);
                }
            }
        }
        private void InitializeInputExchange(IModel channel)
        {
            channel.ExchangeDeclare(
                exchange: $"{_serviceName}.Input.E.Direct.{Env}",
                type: "direct");

            channel.ExchangeBind(
                destination: $"{_serviceName}.Input.E.Direct.{Env}",
                source: $"RabbitMqPocMessageHub.E.Fanout.{Env}",
                routingKey: "");
        }