Search code examples
rabbitmqspring-amqp

Does a binding need to match the arguments/settings with the queue in Spring RabbitMQ?


Given the following Queue (RabbitMQ) bean in Spring Boot...

@Bean
Queue exampleQueue() {
    return QueueBuilder.durable("exampleQueue")
            .quorum()
            .singleActiveConsumer()
            .build();
}

@Bean
public DirectExchange directExchange() {
    return ExchangeBuilder.directExchange("direct-exchange")
            .durable(true)
            .build();
}

... I found the following Binding definition in the code I'm reviewing:

@Bean
Binding exampleBinding(DirectExchange directExchange, Queue exampleQueue) {
    final Binding binding = BindingBuilder.bind(exampleQueue)
            .to(directExchange)
            .with("example-routing-key");
    binding.addArgument("x-queue-type", "quorum");
    binding.addArgument("x-single-active-consumer", "true");
    return binding;
}

My question is: Are these additional arguments x-queue-type and x-single-active-consumer necessary at all? My understanding is, that the queue already defines these settings and, thus, the binding does not to explicitly repeat them?


Solution

  • Those are queue arguments, not binding arguments so, no, they are not necessary; presumably RabbitMQ just ignores them.