my-queue
。Durable
就得。my-queue
classic
D
係 durable。Args
裡面有 x-queue-type: classic
。idle
0
1 - Non-persistent
就得。foo
。String (default)
就得。Automatic ack
。Auto string / base64
就得。10
,就算多過實際存在既訊息數量都冇問題。(AMQP default)
my-queue
○
(白色代表 false
,requeue 既訊息先會係 true
)1
foo
false
),因為呢個訊息係第一次接收。true
),因為呢個訊息喺第一次接收之後被 requeue,而家接收既係第二次傳遞同一個訊息。my-direct-exchange
。my-direct-queue
。my-direct-exchange
。foo
。foo
(要同 binding key 一樣)。my message content
。1
個訊息。foo
作為 routing key(唔輸入,或者輸入另一個值),佢就會彈出黃色底既 popup,寫住「Message published, but not routed.」,咁係因為冇一個 binding 既 binding key 係 match 到呢個 routing key。my-fanout-exchange
。my-fanout-queue
。my-fanout-exchange
。foo
,或者唔輸入都得。my message content
。1
個訊息。foo
、唔輸入,或者輸入另一個值),都一樣可以發送到訊息,咁係因為 fanout exchange 唔會理 routing key 或者 binding key。my-headers-exchange
。my-headers-queue
。my-headers-exchange
。h1
= foo
(String
)h2
= bar
(String
)h1
= foo
(String
)h2
= bar
(String
)my message content
。1
個訊息。my-topic-exchange
。my-topic-queue
。my-topic-exchange
。foo.#
。foo.123
(要係一個 match 到 foo.#
接受既值)。my message content
。1
個訊息。foo.#
binding key 接受既 routing key 例子:foo
、foo.
、foo..
、foo.#
、foo.1
、foo.a
、foo.abc
foo.#
binding key 唔接受既 routing key 例子:bar.
、bar.123
biz-exchange
direct
biz-queue
x-dead-letter-exchange
:my-dlx
x-dead-letter-routing-key
:my-dlkey
biz-exchange
biz-queue
biz-key
my-dlx
direct
my-dlq
x-dead-letter-exchange
:biz-exchange
(String
)x-dead-letter-routing-key
:biz-key
(String
)x-message-ttl
:10000
(Number
)(等於 10
秒)my-dlx
my-dlq
my-dlkey
biz-key
。my message content
。1
個訊息。1
個訊息。10
秒)。1
個訊息。選項 | 解釋 |
---|---|
Durable | 個 exchange 會喺 RabbitMQ 重新啟動之後都繼續存在。 |
Auto-delete | 當最後一個 binding 被解除,RabbitMQ 就會自動刪除呢個 exchange。 |
Direct type | Binding key 會係 exact match。 |
Fanout type | 唔需要 binding key,就算提供左都冇用,所有 bind 左既 queues 都必定會收到所有訊息。 |
Headers type | 用特定既 key-value arguments 黎 match。 |
Topic type | Binding key 可以係 exact match,亦可以運用 wildcard characters——* 代表 wildcard 單字;# 代表 wildcard 任意長度(0 至 N )既文字。 |
選項 | 解釋 |
---|---|
Durable | 個 queue 會喺 RabbitMQ 重新啟動之後都繼續存在。 |
Auto-delete | 當最後一個 consumer cancel 或者 disconnect 左,RabbitMQ 就會自動刪除呢個 queue。 |
Exclusive | 當佢所屬既 connection close 左,RabbitMQ 就會自動刪除呢個 queue。 |
Message TTL(x-message-ttl arg) | Queue level 既 time-to-live,一個訊息如果超過呢個時間就會 expire,consumers 唔會收到已經 expire 左既訊息。如果有 dead letter exchange 既 args,當訊息喺 head 位置,RabbitMQ 就會將佢轉移去 dead letter exchange。 |
Auto-expire(x-expires arg) | 數值係 millisecond 數字(5000 等於 5 秒)。當冇任何 consumer 連接住呢個 queue(一建立 queue 既時候都算),RabbitMQ 就會開始計時,一到左時間,RabbitMQ 就會自動刪除呢個 queue。 |
Single active consumer(x-single-active-consumer arg) | 如果我地既訊息一定要按入 queue 既先後次序處理,如果想保持住多個相同 consumer 既 app instances,咁我地可以用 single active consumer 選項,咁所有訊息都只會傳遞到同一個 consumer,保證處理訊息既先後次序。 |
Dead letter exchange(x-dead-letter-exchange ) | 如果傳遞失敗,RabbitMQ 可能會將佢轉移到呢個 dead letter exchange。 |
Dead letter routing key(x-dead-letter-routing-key ) | RabbitMQ 將訊息轉移到 dead letter exchange 既時候會用既 routing key。 |
選項 | 解釋 |
---|---|
Binding key(或者 routing key) | 提供 filter 訊息既作用。一個訊息如果要由 exchange X1 去到 queue Q1 ,呢個訊息既 routing key 一定要 match 到 Q1 同 X1 之間既 binding 既 binding key。我地應該根據 exchange type 去輸入符合我地需要既 binding key。 |
Arguments | 用喺 headers exchange 既 bindings 度,只有 match 到曬所有 arguments 既值既訊息先會 route 到去個 queue 度。 |
選項 | 解釋 |
---|---|
Delivery mode | Persistent(1 )會先寫落 persistent storage(disk),如果 RabbitMQ crash 左既話都會喺返度。Non-persistent(2 )就唔會寫落 disk。 |
選項 | 解釋 |
---|---|
Reject | 係 AMQP 既標準,用黎拒絕單一訊息。 |
Nack | Negative acknowledgement 係 RabbitMQ 獨有既功能,可以同時拒絕對多個訊息。 |