In ActiveMQ clustering, how to find the consumer who picked a particular message or set of messages?

149 Views Asked by At

We have set of queues and camel routes have been written to consume messages from the queue - queues live in an ActiveMQ server and camel routes in Apache Karaf. We have put up a cluster with multiple karaf nodes; problem is that these messages get read by camel routes in different nodes; is there a way to know the consumer who picked a particular message or set of messages? I googled around but did not get any head way so I am here asking your help.

3

There are 3 best solutions below

2
On BEST ANSWER

You could try using a combination of:

  1. ActiveMQ TraceBrokerPathPlugin: Configure this plugin in each node of your cluster. It will append the 'brokerName' to a JMS header in the message as it goes through the nodes.
  2. Enable Message History in Camel Context: Configure all you camel context to enable message history. It will include an exchange property with a list of org.apache.camel.MessageHistory with routing metadata.
  3. Enable trace or implement EventNotifier to write the information you need into a log file.
  4. (Optional) Implement Correlation Identifier to better identify the flow of your messages within a conversation/transaction.
0
On

There is no tracking of consumed messages in ActiveMQ except for advisory messages. The solution is to let each Camel consumer announce that it processed a message somehow. There are tons of way to do that, such as writing to a log file, sending logs to a database, email or whatever depending on frequency and need. Of course, you could write some plugin or similar to ActiveMQ and have it log such information for your need, but that seems awkward.

0
On

For debugging purposes you can use Hawtio to monitor your Camel nodes and trace the messages consumed by the routes. You can also add logging to your routes on the fly in there.