我指定稱爲MyQueue
的RabbitMQ的服務器上的隊列。它是耐用的,並有x-dead-letter-exchange
設置爲MyQueue.DLX
。AMQP寶石規定成爲一紙空文交換
(我也有一個交換稱爲MyExchange
綁定到隊列中,另一交換稱爲MyQueue.DLX
,但我不認爲這是問題的重要)
如果我使用Ruby的amqp
寶石訂閱者消息我會做這樣的:
# Doing this before and in a new thread has to do with how my code is structured
# shown here in case it has a bearing on the question
Thread.new do
AMQP.start('amqp://guest:[email protected]:5672')
end
EventMachine.next_tick do
channel = AMQP::Channel.new(AMQP.connection)
queue = channel.queue("MyQueue", :durable => true, :'x-dead-letter-exchange' => "MyQueue.DLX")
queue.subscribe(:ack => true) do |metadata, payload|
p metadata
p payload
end
end
如果我執行這個代碼隊列,並已創建和綁定交易所(因爲它們需要在我的設置),那麼RabbitMQ的拋出在其日誌中出現以下錯誤:
=ERROR REPORT==== 19-Aug-2013::14:25:53 ===
connection <0.19654.2>, channel 2 - soft error:
{amqp_error,precondition_failed,
"inequivalent arg 'x-dead-letter-exchange'for queue 'MyQueue' in vhost '/': received none but current is the value 'MyQueue.DLX' of type 'longstr'",
'queue.declare'}
這似乎是說,我沒有指定了相同的死信Exchange作爲預先存在的隊列 - 但我相信我與queue = ...
線。
任何想法?
因此,如果您沒有任何隊列或交換機聲明,您的代碼是否能夠成功工作? –
如果我宣佈我的隊列沒有死信交換集,那麼是的,它確實有效 - 我認爲這只是我不知道如何用ruby gem指定DLX。 –