简体   繁体   中英

Need to add/update the arguments of an durable rabbitmq queue

I want to configure dead letter to my exisiting queue. For that, i tried adding arguments(x-dead-letter-queue) to my Durable rabbitmq queue. So when i updated my bean definition

From

@Bean
Queue queue() {
   return QueueBuilder.durable("my-queue")
          .build();

To

@Bean
Queue queue() {
   return QueueBuilder.durable("my-queue")
          .withArgument("x-dead-letter-exchange", "dead-letter.exchange")
          .build();
}

i get an exception

Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'my-queue' in vhost '/': received 'dead-letter.exchange' but current is None, class-id=50, method-id=10)

I read that i could apply policy to update a durable queue. So, i tried the below command

rabbitmqctl set_policy dlq_policy_name "my-queue" '{"dead-letter-exchange": "dead-letter.exchange"}'

But still the arguments are not set on the queue my-queue.

Can you help me achieve this?

PS. I would rather avoid deleting and recreating the queue, but if it is the last option, then only i would consider that.

Answering my own post...

So, after setting policy, you don't see the policy setting in the arguments of the queue.

Checking

rabbitmqctl list_queues name arguments policy

would give you arguments as well as policies for a queue.

Then we would have to remove the argument setting in the java code and depending upon the policy set the queue would work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM