Search code examples
spring-bootspring-amqpspring-rabbit

To unbind routing keys from rabbitmq using declarables


How to unbind routing keys from already created queue using declarables. I am using below code to declare queues and bind the routing keys

 @Bean
public Declarables ds() {
Declarables declarables = new Declarables();
declarables.getDeclarables().add(topicExchange());
declarables.getDeclarables().add(new Queue("queueName", false);
for (String chain : chainNames)
    declarables.getDeclarables().add(new Binding("queueName", Binding.DestinationType.QUEUE,
                                "XYZ", "routing key pattern", null));
return declarables;
}

Solution

  • There is currently no support for unbinding via Declarables; you can do it manually with

    rabbitAdmin.removeBinding(...);
    

    But you should not do that in a @Bean definition.