重播通过ActiveMQ发送的消息 [英] Replay Messages sent over ActiveMQ

查看:159
本文介绍了重播通过ActiveMQ发送的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法来创建通过队列发送的每条消息的副本,以便在需要时,用户可以浏览以前传输的消息列表并通过单击按钮多次重播它们?

Is there an easy way to create a copy of every message sent over a queue, so that if needed, the user could browse the list of previously transmitted messages and replay them numerous times with the click of a button?

我有程序X向队列发送消息,程序Y然后读取它。我希望能够重放以前发送的消息,而不必返回编程X并重新生成它。

I have program X that sends a message to a queue and program Y then reads it in. I would like to be able to replay a message that was previously sent without having to go back to program X and regenerate it again.

推荐答案

如果您没有太多消息或太多,有很简单的入门方法很多队列。

There are easy ways to get started, if you have not too many messages or too many queues.

首先,您可以设置将邮件复制到复制队列。使用此策略,每个队列必须执行一次此操作。像这样在 activemq.xml

First, you could setup copying of messages to a "copy queue". This has to be done once per queue with this strategy. Like this in activemq.xml

    <destinationInterceptors>
      <virtualDestinationInterceptor>
        <virtualDestinations>
          <compositeQueue name="INVOICE.OUT">
            <forwardTo>
              <queue physicalName="INVOICE.IN" />
              <queue physicalName="INVOICE.COPY" />
            </forwardTo>
          </compositeQueue>
        </virtualDestinations>
      </virtualDestinationInterceptor>
    </destinationInterceptors>

然后使用工具浏览COPY队列上的消息,如果需要,将其重新发送到OUT队列。我喜欢 Hermes JMS 工具。

Then use a tool to browse through the messages on the COPY queue, and if needed, resend them to the OUT queue. I like the Hermes JMS tool for such things.

如果你想要更有趣的东西,你可以阅读镜像队列

If you want something more fancy, you could read up on mirrored queues.

还有另一种简单的方法可以轻松复制所有邮件。

There is another rather simple way to achieve easy copy of all messages.

使用与activemq捆绑在一起的apache-camel。
camel.xml 中的这个配置将实现所有消息自动复制到以FOO开头的队列。*
此路由需要一些修复复制队列名称,但在priniple中,它作为一次性配置进行窃听。

Use apache-camel that is bundled with activemq. This config inside camel.xml would achieve automatic copy of all messages to queues that begins with FOO.* This route would need some fixup of the copy queue name, but in priniple it works as a one time config for wiretapping.

<route>
   <from uri="activemq:FOO.>"/>
   <setHeader headerName="CamelJMSDestination">
     <simple>COPY.${header.JMSDestination}</simple>
   </setHeader>
   <to uri="activemq:dummy"/>
</route>

这里一个非常重要的方面是,如果存储所有消息,您的服务器将随着时间的推移而填满。我建议你阅读 ActiveMQ内存管理或者,只保留给定时间范围内的消息副本。这可以自动化,因为发送系统实际上可以设置消息到期,以便在几天/几周/几个月后自动删除消息。

A very important aspect here is that your server will fill up over time if you store all messages. I suggest you read up on ActiveMQ memory management or, just keep message copies for given timeframe. This can be automated in the sense that the sending system can actually set a message expiry so that messages get deleted automatically after a number of days/weeks/months.

这篇关于重播通过ActiveMQ发送的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆