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

Create queues with some x-max-priority values fails #165

Closed
ezequielgarcia88 opened this issue Jun 24, 2015 · 8 comments
Closed

Create queues with some x-max-priority values fails #165

ezequielgarcia88 opened this issue Jun 24, 2015 · 8 comments
Assignees

Comments

@ezequielgarcia88
Copy link

If if create a queue with x-max-priority at 255 it fails with the following error:

Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - invalid arg 'x-max-priority' for queue 'tasks' in vhost '/': {value_negative,-1}"

This is my example code:

require('amqplib').connect('amqp://guest:guest@localhost:5672').then(function(conn) {
    return conn.createChannel().then(function(ch) {
        return ch.assertExchange('tasks-ex', 'fanout').then(function() {
            return ch.assertQueue('tasks', {
                arguments : {
                    'x-max-priority' : 255
                }
            }).then(function (qok) {
                return ch.bindQueue(qok.queue, 'tasks-ex', '').then(function () {
                    return qok.queue;
                });
            }).then(function (queue) {
                return ch.consume(queue, function (msg) {
                    if (msg !== null) {
                        console.log(' [x] Received "%s"', msg.content.toString());
                        ch.ack(msg);
                    }
                },{
                    noAck : false
                });
            });
        });
    });
}).then(null, console.warn);

Do you know why this happens?

@michaelklishin
Copy link

The message says what the problem is: you already have a queue named tasks and it has different attributes (headers, in this case). Delete it and declare it again with the headers you want.

@ezequielgarcia88
Copy link
Author

Hi, thanks for the quick answer. I don't have the queue created in RabbitMQ, and also the example code works by only changing the x-max-priority to 256.

This is the error I get if the queue was already created with different attributes:

Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - inequivalent arg 'x-max-priority' for queue 'tasks' in vhost '/': received '258' but current is '256'"

@michaelklishin
Copy link

@ezequielgarcia88

inequivalent arg 'x-max-priority' for queue 'tasks' in vhost '/': received '258' but current is '256'"

suggests that you do have that queue in vhost /. In an unrelated note, 256 priorities is excessive and will introduce a lot of unnecessary overhead. 5-10 should be sufficient for most use cases.

@squaremo
Copy link
Collaborator

In the first example, the error was invalid arg 'x-max-priority' for queue 'tasks' in vhost '/': {value_negative,-1}, which suggests to me some weird encoding is going on. Maybe RabbitMQ expects an unsigned encoding, but the client library uses a signed encoding (because how is it supposed to know, for arbitrary arguments).

@squaremo
Copy link
Collaborator

Iiiiinteresting: rabbitmq/rabbitmq-server@a640f74

@taoyanli0808
Copy link

Here's a tour.

@Laksh47
Copy link

Laksh47 commented Feb 22, 2018

replace the 'x-max-priority' with 'maxPriority'
reference: http://www.squaremobius.net/amqp.node/channel_api.html#channel_assertQueue

@tholisam-sasikala
Copy link

tholisam-sasikala commented Jun 22, 2019

data queue should be created with arg x-max-length-bytes" = int64(1000000000)
Max length should be set in the call to queue declare using the params argument, not externally with rabbitmqctl...

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

6 participants