Search code examples
javarabbitmqspring-rabbitrabbitmq-exchange

Why am I getting the RabbitMQ exchange exception?


Here are my queues setting for tests, they are incorrect but they work:

mq:
  username: guest
  password: guest
  host: localhost
  port: ${QA_RABBIT_LISTENER}
  ig-smev3:
    listener:
      vhost: /
      exchangeName: igSmev3Listener
      queueName: igSmev3-ListenerQueue
      routingKey: igSmev3-Listener
    producer:
      vhost: /
      exchangeName: igSmev3Producer
      queueName: igSmev3-ProducerQueue
      routingKey: igSmev3-Producer

If I set

vhost: /
      exchangeName: igSmev3Producer
      queueName: igSmev3ProducerQueue
      routingKey: igSmev3Producer

I will get an error:

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'igSmev3Listener' in vhost '/': received 'fanout' but current is 'direct', class-id=40, method-id=10)

What's wrong?


Solution

  • inequivalent arg 'type' for exchange 'igSmev3Listener' in vhost '/': received 'fanout' but current is 'direct'

    You have already an igSmev3Listener exchange on the broker and its type is fanout, but you provide the same name and with default type - direct.

    Consider to remove that exchange before starting your application.

    This feels like a Deja Vu with this similar question with similar properties: How to set x-dead-letter-exchange in Rabbit?