Reputation: 566
I need to bind a fanout exchange to the default exchange in Spring Boot RabbitMQ client and I can't do it. When I try the code below, I see no errors, but the exchange is not bound (at least it doesn't show in rabbitmq admin nor are the messages routed to that exchange). My code:
A message with routing key testq put into testex exchange disappears - isn't delivered to testq queue.
@Bean
FanoutExchange testExchange() {
return new FanoutExchange("testex");
}
@Bean
Binding testExchangeToDefaultBinding() {
return new Binding("", DestinationType.EXCHANGE, "testex", null, null);
}
@Bean
Queue testQueue() {
return new Queue("testq");
}
Is it impossible to bind it that way?
Edit: Is there any other way to do something like that?
Upvotes: 1
Views: 1691
Reputation: 106
The default exchange is a direct exchange with no name (empty string) pre-declared by the broker.
The default exchange is implicitly bound to every queue, with a routing key equal to the queue name. It is not possible to explicitly bind to, or unbind from the default exchange.
Upvotes: 5