Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set queue x-max-length parameter #130

Open
rogeriobiondi opened this issue Jun 7, 2017 · 3 comments
Open

How to set queue x-max-length parameter #130

rogeriobiondi opened this issue Jun 7, 2017 · 3 comments

Comments

@rogeriobiondi
Copy link

rogeriobiondi commented Jun 7, 2017

Hello,

I'm trying to setup the x-max-length parameter in my queues:

rabbitmqctl set_policy Ten "^one-meg$" '{"x-max-length": 10}' --apply-to queues

But when trying to use rabbit.js I'm getting the following error:

Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - inequivalent arg 'x-max-length' for queue 'WORKER' in vhost '/': received none but current is the value '10' of type 'signedint'"

In python (pika) I can set this parameter the following way:

credentials = pika.PlainCredentials('user', 'pw')
parameters = pika.ConnectionParameters(host='127.0.0.1',
port=5672,
virtual_host='/',
credentials = credentials,
heartbeat_interval = 60)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
args = { "x-max-length": 10 }
channel.queue_declare(queue="WORKER", durable=True, arguments=args)

May you clarify me how this could be accomplished using rabbit.js?

Thank you very much for your help.

Best regards,
Rogerio

@agrski
Copy link

agrski commented Apr 11, 2018

Replying for anyone encountering this issue.

I had the opposite error in Python:
pika.exceptions.ChannelClosed: (406, "PRECONDITION_FAILED - inequivalent arg 'x-max-length' for queue 'test' in vhost '/': received the value '1' of type 'signedint' but current is none")

The problem was that the queue already existed and had been set up without the option set so defaulted to having no maximum queue length.
When Rabbit receives the new queue declaration, it sees that it conflicts with existing queue options and prevents the queue changing whilst "in use".
There are two solutions:

  1. If the queue isn't actually in use, delete it then declare it using the correct options.
  2. Ensure any declarations for the queue use the same configuration/options so there's no conflict.

For anyone encountering this, you should go with solution (2) - solution (1) is only for fixing it so you can use solution (2).

@gordania
Copy link

gordania commented May 8, 2019

@agrski is there any way to update a queue configs such as x-max-length on the fly without deleting the queue? I'm receiving the same error when trying to add the x-max-length config to a queue in my python code. A solution through code or rabbit's API or GUI would be welcomed!

So far I've only been able to resolve by deleting the queue which isn't desirable

@iamjenechka
Copy link

iamjenechka commented Nov 20, 2021

from your working directory, try:

grep -RIn 'x-max-length' .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants