There are easy ways to get started if you have too many messages or too many queues.
First, you can configure message copying to the “copy queue”. This strategy must be run once in a queue. How is it in activemq.xml
<destinationInterceptors> <virtualDestinationInterceptor> <virtualDestinations> <compositeQueue name="INVOICE.OUT"> <forwardTo> <queue physicalName="INVOICE.IN" /> <queue physicalName="INVOICE.COPY" /> </forwardTo> </compositeQueue> </virtualDestinations> </virtualDestinationInterceptor> </destinationInterceptors>
Then use the tool to view messages in the COPY queue, and send them to the OUT queue if necessary. I like the Hermes JMS tool for such things.
If you need something more interesting, you can read mirrored queues .
There is another fairly simple way to achieve a simple copy of all messages.
Use apache-camel, which is associated with activemq. This configuration inside camel.xml will provide an automatic copy of all messages in the queue starting with FOO. * For this route, some correction of the name of the copy queue will be required, but in principle, it works as a one-time configuration for listening.
<route> <from uri="activemq:FOO.>"/> <setHeader headerName="CamelJMSDestination"> <simple>COPY.${header.JMSDestination}</simple> </setHeader> <to uri="activemq:dummy"/> </route>
A very important aspect is that your server will fill up over time if you save all messages. I suggest you read ActiveMQ Memory Management or just save a copy of messages for a given time frame. This can be automated in the sense that the sending system can indeed set the expiration date of the message so that messages are automatically deleted after a few days / weeks / months.
source share