Results 1 to 2 of 2

Thread: Spring amqp redeclare exchange and all queue

  1. #1
    Join Date
    Dec 2012
    Posts
    9

    Default 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. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,024

    Default

    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() {...});
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •