streadway / amqp

Go client for AMQP 0.9.1
http://godoc.org/github.com/streadway/amqp
BSD 2-Clause "Simplified" License
4.88k stars 621 forks source link

Get "unexpected command received" error when declare a queue concurrently #444

Closed henry42 closed 4 years ago

henry42 commented 4 years ago

I have two clients, each runs by

  1. new channel,
  2. declare exchange
  3. declare queue
  4. bind
  5. ...

two clients using same named queue so that they can consume the tasks in this queue one by one, the queue's options is like

    q, err := ch.QueueDeclare(
    "same", // name
    true,          // durable
    false,         // delete when unused
    false,         // exclusive
    false,         // no-wait
    amqp.Table{
        "x-dead-letter-exchange":   "something"
        "x-dead-letter-routing-key": "something.droped",
    },
)

but when I started the two clients at same time, sometimes I got

Failed to declare a queue: Exception (503) Reason: "unexpected command received"

It did not often happen, and I could start successfully if I tried the fail one again. It confuses me and I do not know which part I do wrong. Thx

btw, I saw the issue, but he is using the same channel, I am not.

henry42 commented 4 years ago

Sorry but my fault, I used same channel to consume two different exchange... so close it.