Amqp: Somehow Channel.QueueDeclare "exclusive" and "durable" flags are mutually infuenced

Created on 3 Dec 2018  路  5Comments  路  Source: streadway/amqp

Here is a minimal example:

package main

import (
    "fmt"

    "github.com/streadway/amqp"
)

func main() {
    conn, _ := amqp.Dial("amqp://guest:guest@localhost/")
    defer conn.Close()
    ch, _ := conn.Channel()
    defer ch.Close()
    q1, err := ch.QueueDeclare("test_qqq", /* durable: */ true, false, /* exclusive: */ false, false, nil)
    handle(err)
    fmt.Println("%+v", q1)
    q2, err := ch.QueueDeclare("test_qqq", /* durable: */ true, false, /* exclusive: */ true, false, nil)
    handle(err)
    fmt.Println("%+v", q2)
}

func handle(err error) {
    if err != nil {
        panic(fmt.Sprintf("%v", err))
    }
}

Using:

  • amqp version v0.0.0-20181107104731-27835f1a64e9
  • RabbitMQ 3.7.3 Erlang 20.2

As you can see, in this example I am trying to recreate same queue twice, first with exclusive:true, then with exclusive:false. It fails as expected, but produces unexpected error message:

Exception (406) Reason: "PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'test_qqq' in vhost '/': received 'false' but current is 'true'"

I spent half an hour looking blankly at my durable: true statement, but actually should be looking into exclusive argument. Is there a way to keep future users from such a loss of time? It should be like args 'durable' and 'exclusive' are in conflict with each other. Or is it RabbitMQ problem?

mailing list material

Most helpful comment

@SergeAx - https://github.com/rabbitmq/rabbitmq-server/issues/1887

Basically, the presence of "exclusive" negates the durable argument, but durable is checked first. I'm fixing it now. Thanks for the code to reproduce the issue.

All 5 comments

See Declaration property equivalence in the Queues guide.

See Declaration property equivalence in the Queues guide.

I understand you may get tens complains like this every week, but i can assure you I've read the docs. The problem not in an error itself or its code, but in error message, which is misleading. It says I must set durable to true, which I already did. Or maybe you are saying that it is a RabbitMQ fault, not your package's, and I should file an issue in their repo?

Update: I've checked the package's source and can see now it's a problem on a RabbitMQ side, sorry. Case closed here.

@SergeAx - https://github.com/rabbitmq/rabbitmq-server/issues/1887

Basically, the presence of "exclusive" negates the durable argument, but durable is checked first. I'm fixing it now. Thanks for the code to reproduce the issue.

@SergeAx apologies, I didn't spot the combination of properties you were using. Indeed most such questions come from complete beginners so I used a canned response.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CodingAgainstChaos picture CodingAgainstChaos  路  3Comments

cenkalti picture cenkalti  路  4Comments

pnuz3n picture pnuz3n  路  17Comments

fho picture fho  路  7Comments

Unlym picture Unlym  路  10Comments