2 回答

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
好吧,雖然我不必修改任何 PHP 代碼,但我確實(shí)必須更改yaml框架級別的配置,因?yàn)槲蚁M业慕鉀Q方案得以保留并成為代碼庫的一部分。
在你的app/config/services/rabbitmq.yaml:
定義生產(chǎn)者:
high_priority:
connection: default
class: Foo\Infrastructure\RabbitMQ\SuppressedProducer
exchange_options:
name: 'high_priority'
type: direct
high_priority_secondary:
connection: default
class: Foo\Infrastructure\RabbitMQ\SuppressedProducer
exchange_options:
name: 'high_priority_secondary'
type: direct
message_hospital:
connection: default
class: Foo\Infrastructure\RabbitMQ\SuppressedProducer
exchange_options:
name: 'message_hospital'
type: direct
定義消費(fèi)者:
high_priority:
connection: default
exchange_options:
name: 'high_priority'
type: direct
queue_options:
name: 'high_priority'
arguments:
x-dead-letter-exchange: ['S', 'high_priority_secondary']
qos_options:
prefetch_size: 0
prefetch_count: 1
global: false
callback: foo.task_bus.consumer
high_priority_secondary:
connection: default
exchange_options:
name: 'high_priority_secondary'
type: direct
queue_options:
name: 'high_priority_secondary'
arguments:
x-dead-letter-exchange: ['S', 'message_hospital']
qos_options:
prefetch_size: 0
prefetch_count: 1
global: false
callback: foo.task_bus.consumer
message_hospital:
connection: default
exchange_options:
name: 'message_hospital'
type: direct
queue_options:
name: 'message_hospital'
qos_options:
prefetch_size: 0
prefetch_count: 1
global: false
callback: foo.task_bus.consumer
現(xiàn)在隊(duì)列看起來像:
由于 DLX 屬性,消息一旦在之前的消息中失敗,就會立即進(jìn)入醫(yī)院隊(duì)列。

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超5個(gè)贊
high_priority_secondary
隊(duì)列應(yīng)該綁定到high_priority_secondary
交換器。 high_priority
隊(duì)列應(yīng)該綁定到high_priority
交換并且應(yīng)該用 聲明x-dead-letter-exchange = high_priority_secondary
。
因此隊(duì)列應(yīng)該用死信交換來聲明。
要測試這一點(diǎn),只需在從隊(duì)列中使用消息時(shí)通過重新排隊(duì)拒絕該消息即可high_priority
。
- 2 回答
- 0 關(guān)注
- 209 瀏覽
添加回答
舉報(bào)