如何监控activeMQ的队列到达和消息发送时间?

时间:2017-03-02 18:50:32

标签: java activemq

是否有办法(第三方软件或编程)监控邮件到达特定队列的时间及其消耗的时间?

类似于消息的内容在17:14:22 565到达并在17:14:22 598消耗或消息被排队N毫秒

我已阅读有关Statistics plugin的内容,但它只是给出了排队邮件的最多和最少时间

2 个答案:

答案 0 :(得分:0)

您可以使用http://activemq.apache.org/advisory-message.html

下面的第一个示例,当消息传递给代理时会收到通知。 消息被消费时要通知的第二个例子。

AdvisorySupport.getMessageDeliveredAdvisoryTopic()
AdvisorySupport.getMessageConsumedAdvisoryTopic()

请参阅下面的示例,以便访问消息属性,例如创建时间,消息到达或离开代理时的进出时间。 以下是属性列表http://activemq.apache.org/activemq-message-properties.html

Spring JMS Producer and Consumer interaction

答案 1 :(得分:0)

一种方法是编写自己的插件。 (http://activemq.apache.org/developing-plugins.html

这很简单,效果与更改activemq代理代码类似。

您可以扩展BrokerFilter类,并覆盖它的方法,如postProcessDispatch(),send()。然后,您可以在自己的代码中记录时间或任何您想要的内容。

我写了一个简单的例子(https://github.com/lcy362/FoxActivemqPlugin/blob/b54d375a6a91a9ec418e779deb69a8b11f7d985a/src/main/java/com/mallow/activemq/FoxBrokerPlugin.java),希望这有用。