Instead of binding the dlx queue to the same routing key as the working
queue, we bind it to the value of the argument
x-dead-letter-routing-key to avoid sending the rejected message to
multiple queues.
Example:
1) Queues a and b are bound to routing key x, in the same exchange;
2) A message is received and consumed successfully by queue a, but queue
b rejects it;
3) The handler would publish the message to the dead-letter exchange using
the routing key x, causing it to end up in both dead-letter queues (a.dlx and b.dlx).
With this change, as long as these two queues where declared with a
different x-dead-letter-routing-key, the message would end up just in
the queue that originally rejected it.
We would probably use the queue name as the x-dead-letter-routing-key
value to guarantee uniqueness.
Instead of binding the dlx queue to the same routing key as the working queue, we bind it to the value of the argument
x-dead-letter-routing-key
to avoid sending the rejected message to multiple queues.Example:
1) Queues
a
andb
are bound to routing keyx
, in the same exchange; 2) A message is received and consumed successfully by queuea
, but queueb
rejects it; 3) The handler would publish the message to the dead-letter exchange using the routing keyx
, causing it to end up in both dead-letter queues (a.dlx
andb.dlx
).With this change, as long as these two queues where declared with a different
x-dead-letter-routing-key
, the message would end up just in the queue that originally rejected it.We would probably use the queue name as the
x-dead-letter-routing-key
value to guarantee uniqueness.