LoginSignup
4
1

More than 5 years have passed since last update.

Requeue時のキューの挿入順序について

Posted at

Message ordering guarantees

Section 4.7 of the AMQP 0-9-1 core specification explains the conditions under which ordering is guaranteed: messages published in one channel, passing through one exchange and one queue and one outgoing channel will be received in the same order that they were sent. RabbitMQ offers stronger guarantees since release 2.7.0.

Messages can be returned to the queue using AMQP methods that feature a requeue parameter (basic.recover, basic.reject and basic.nack), or due to a channel closing while holding unacknowledged messages. Any of these scenarios caused messages to be requeued at the back of the queue for RabbitMQ releases earlier than 2.7.0. From RabbitMQ release 2.7.0, messages are always held in the queue in publication order, even in the presence of requeueing or channel closure.

2.7.0から仕様が変更になり、リキューされたキューは一番最後尾に追加されるのではなくキュー内の元居た場所に戻されるようになる。
この仕様変更によりキュー内での順序性がより強く保証されることになるが、ワーカーのエラーを誘発するような変なメッセージがいると、そいつが延々とワーカーをブロックしつづける危険性がある。

単純にリキューするのではなく、DeadLetterQueueの活用も検討するとよいかもしれない。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1