Search code examples
spring-bootrabbitmqspring-amqpspring-rabbitrabbitmq-exchange

Bind rabbitmq default exchange to other exchange


Is it possible to bind rabbitMq default exchange to other exchange?

I would like to forward messages from my bar exchange to default exchange, but I don't know how.

For two custom exchanges - foo and bar it works fine:

    @Bean
    Binding fooExchangeToBarExchange(FanoutExchange fooExchange, FanoutExchange barExchange) {
        return BindingBuilder.bind(fooExchange).to(barExchange);
    }

but similar with default exchange doesn't work

    @Bean
    DirectExchange defaultExchange() {
        return new DirectExchange("");
    }

    @Bean
    Binding defaultExchangeToBarExchange(DirectExchange defaultExchange, FanoutExchange barExchange) {
        return BindingBuilder.bind(defaultExchange).to(barExchange);
    }


Solution

  • No it is not allowed:

    Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=403, reply-text=ACCESS_REFUSED - operation not permitted on the default exchange, class-id=40, method-id=30)