private RabbitConfig.IBinding NotPartitionedBinding(
            IExchange exchange,
            Queue queue,
            string rk,
            RabbitCommonOptions extendedProperties)
        {
            var routingKey = rk;

            if (routingKey == null)
            {
                routingKey = "#";
            }

            var arguments = new Dictionary <string, object>();

            foreach (var entry in extendedProperties.QueueBindingArguments)
            {
                arguments.Add(entry.Key, entry.Value);
            }

            switch (exchange)
            {
            case TopicExchange topic:
            {
                var binding = BindingBuilder.Bind(queue).To(topic).With(routingKey);
                DeclareBinding(queue.QueueName, binding);
                return(binding);
            }

            case DirectExchange direct:
            {
                var binding = BindingBuilder.Bind(queue).To(direct).With(routingKey);
                DeclareBinding(queue.QueueName, binding);
                return(binding);
            }

            case FanoutExchange fanout:
            {
                var binding = BindingBuilder.Bind(queue).To(fanout);
                DeclareBinding(queue.QueueName, binding);
                return(binding);
            }

            case HeadersExchange:
            {
                var binding = new RabbitConfig.Binding(queue.QueueName + "." + exchange.ExchangeName + ".binding", queue.QueueName, DestinationType.QUEUE, exchange.ExchangeName, string.Empty, arguments);
                DeclareBinding(queue.QueueName, binding);
                return(binding);
            }

            default:
                throw new ProvisioningException("Cannot bind to a " + exchange.Type + " exchange");
            }
        }
        private void AutoBindDLQ(string baseQueueName, string routingKey, RabbitCommonOptions properties)
        {
            var autoBindDlq = properties.AutoBindDlq.Value;

            _logger.LogDebug("autoBindDLQ=" + autoBindDlq + " for: " + baseQueueName);
            if (autoBindDlq)
            {
                string dlqName;
                if (properties.DeadLetterQueueName == null)
                {
                    dlqName = ConstructDLQName(baseQueueName);
                }
                else
                {
                    dlqName = properties.DeadLetterQueueName;
                }

                var dlq = new Queue(dlqName, true, false, false, GetQueueArgs(dlqName, properties, true));
                DeclareQueue(dlqName, dlq);
                var dlxName = GetDeadLetterExchangeName(properties);
                if (properties.DeclareDlx.Value)
                {
                    DeclareExchange(dlxName, new ExchangeBuilder(dlxName, properties.DeadLetterExchangeType).Durable(true).Build());
                }

                var arguments = new Dictionary <string, object>();

                properties.DlqBindingArguments?.ToList().
                ForEach(entry => arguments.Add(entry.Key, entry.Value));

                var dlRoutingKey  = properties.DeadLetterRoutingKey ?? routingKey;
                var dlBindingName = dlq.QueueName + "." + dlxName + "." + dlRoutingKey + ".binding";
                var dlqBinding    = new RabbitConfig.Binding(dlBindingName, dlq.QueueName, DestinationType.QUEUE, dlxName, dlRoutingKey, arguments);
                DeclareBinding(dlqName, dlqBinding);
                if (properties is RabbitConsumerOptions options && options.RepublishToDlq.Value)
                {
                    /*
                     * Also bind with the base queue name when republishToDlq is used, which does not know about partitioning
                     */
                    var bindingName = dlq.QueueName + "." + dlxName + "." + baseQueueName + ".binding";
                    DeclareBinding(dlqName, new RabbitConfig.Binding(bindingName, dlq.QueueName, DestinationType.QUEUE, dlxName, baseQueueName, arguments));
                }
            }
        }