Skip to content

Instantly share code, notes, and snippets.

@maiha
Last active April 19, 2021 12:55
Show Gist options
  • Save maiha/6b5318de0f068068adf3558c0d091319 to your computer and use it in GitHub Desktop.
Save maiha/6b5318de0f068068adf3558c0d091319 to your computer and use it in GitHub Desktop.

Queue

制限

作成

Name
Durable (the queue will survive a broker restart)
Exclusive (used by only one connection and the queue will be deleted when that connection closes)
Auto-delete (queue that has had at least one consumer is deleted when last consumer unsubscribes)
Arguments (optional; used by plugins and broker-specific features such as message TTL, queue length limit, etc)

Consume

nackはrejectの上位互換。RabbitMQではackとnackだけ使えばいい。

  • ack : AMQPのack。multipleサポート
  • nack : AMQPのreject。multipleサポート
  • reject : AMQPのreject。

永続化

  • キュー及びメッセージはデフォルトで永続化されない (都度IOが発生してパフォーマンスが一気に落ちるため)
  • 永続化にはかなり設定が必要

確認箇所

  • exchange が durable で定義されている
  • queue が durable で定義されている
  • publish 時のメッセージのプロパティーがpersistent(delivery_mode=2)になっている
  • RabbitMQはホスト名を永続化に利用する (EDPの制約) docker-library/rabbitmq#106 (comment)

priority message

キューの定義時に x-max-priority オプションを設定すると、優先度付けされたメッセージを格納できる。 (3.5.0↑)

  • https://www.rabbitmq.com/priority.html
  • x-max-priority : 最大優先度値。1-255 までの正数。個数に比例してCPUを使う。1-10が推奨されている。
  • priority : publish時に basic.properties で指定。0-255。値が高いほど優先。
  • priorityが未指定の場合、0として処理される

scheduling

Delayed Message Plugin (RabbitMQ-3.5.8)

  • 遅延実行するplugin
  • 🟩 x-delay でmsecを指定するだけで使える
  • 🟥 AWS(AmazonMQ)ではpluginは未サポート (多分)
  • 🟥 データ量が増えると遅延が激しい(数分~数日(100万件)) rabbitmq/rabbitmq-delayed-message-exchange#72
  • 🟥 ロストする危険性がある

dead-letter exchanges (RabbitMQ-2.8.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment