Saturday, 15 October 2011

Copy Messages from one ActiveMQ instance to another with Apache Camel and Groovy

This is just a quick example showing how I have used a little groovy script (it doesn't need to be groovy) to quickly fix or transfer messages from one ActiveMQ queue to another. In the example below the script simple re-routes messages from one instance to another instance using Apache Camel. I have used this before to also fix errors in messages and re--process them before placing back on another or the same queue. It also can be used to quickly move failed messages from a failure queue to the live queue. Scripts like these are easier to use when the message contents are of a standard/open type, i.e. xml, json, raw text etc. This way you can easily parse, fix and modify message bodies without any complex logic or translation.