在RabbitMQ管理UI中查看延迟消息

时间:2017-02-23 13:53:45

标签: rabbitmq

我已根据this文章成功安排了邮件,但是当我将延迟邮件发布到绑定队列时。我无法立即看到队列中的消息。 x-delayed-type 在某个地方交换插件缓冲消息,直到时间到了。

无论如何(配置)是否在延迟时间到来之前在管理插件中看到这些延迟消息?

2 个答案:

答案 0 :(得分:2)

延迟消息存储在Mnesia内,如下:

enter image description here

因此您无法在管理UI中看到它。

修改

你云使用:

rabbitmqctl eval 'ets:tab2list(rabbit_delayed_messagerabbit@Your_HOST_NAME).'

例如: ➜ sbin ./rabbitmqctl eval 'ets:tab2list(rabbit_delayed_messagerabbit@mac).' [{delay_entry, {delay_key,1487934959224, {exchange, {resource,<<"/">>,exchange,<<"my-exchange">>}, 'x-delayed-message',true,false,false, [{<<"x-delayed-type">>,longstr,<<"direct">>}], undefined,undefined, {[],[]}}}, {delivery,false,false,<10495.911.0>, {basic_message, {resource,<<"/">>,exchange,<<"my-exchange">>}, [<<>>], {content,60, {'P_basic',undefined,undefined, [{<<"x-delay">>,signedint,90000}], undefined,undefined,undefined,undefined,undefined, undefined,undefined,undefined,undefined,undefined, undefined}, <<32,0,0,0,0,13,7,120,45,100,101,108,97,121,73,0,1,95,144>>, rabbit_framing_amqp_0_9_1, [<<"delayed payload">>]}, <<174,59,245,237,135,189,175,240,121,105,31,191,47,97,189,156>>, false}, undefined,noflow}, #Ref<10495.0.1.3514>},

(播放量可能无法读取)

<强> EDIT2

此功能将从版本3.7.0

开始提供

https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/issues/3

答案 1 :(得分:0)

如果您确实需要在管理界面中查看消息,并且如果您不能等待Gabriele提到的3.7.0,您可以忽略该插件,而是将TTL和DLX结合起来以延迟消息传递。

您可以将消息发布到队列,该消息将在TTL之后使其消息过期(并且您可以从此队列中查看消息)。然后,您可以使用死信路由密钥将消息重新路由到交换机,以便消息最终出现在您使用的队列中,如here所述。

# declare a queue with the DELAYED_QUEUE name
ch.queue(DELAYED_QUEUE, arguments: {
  # set the dead-letter exchange to the default queue
  'x-dead-letter-exchange' => '',
  # set the routing key into the destination queue name
  'x-dead-letter-routing-key' => DESTINATION_QUEUE,
  # the time in milliseconds to keep the message in the queue
  'x-message-ttl' => 3000
})
# publish to the default exchange with the the delayed queue name 
# as routing key, so that the message ends up in the delayed queue
ch.default_exchange.publish 'message content', routing_key: DELAYED_QUEUE