Announcement Announcement Module
Collapse
No announcement yet.
Spring amqp redeclare exchange and all queue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring amqp redeclare exchange and all queue

    Hi all! I have one exchange and two queue, when I run my project and exchange (and queue) already declare, i am get exception:

    Code:
    ... Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - cannot redeclare exchange 'defaultExchange' in vhost '/' with different type, durable, internal or autodelete value, class-id=40, method-id=10), null, ""}...
    How avoid this exception ? if I need in often redeploy me project.

    my code:
    Code:
            rabbitAdmin.declareExchange(exchange);
            rabbitAdmin.declareQueue(queue1);
            rabbitAdmin.declareQueue(queue2);
    Sorry for my bad English

  • #2
    You can't change attributes when re-declaring a queue; they have to be the same if the queue already exists.

    You can use Channel.queueDeclarePassive() to check if the queue exists already.

    rabbitAdmin.getRabbitTemplate().execute (new ChannelCallback() {...});

    Comment

    Working...
    X