1

I have built several Mule processes that consume messages from jms queues (ActiveMQ). Whenever a Mule component throws an exception, the transaction that consumes the messages rollback and the message gets redelivered to the original queue. After a few tries, it will be sent to a dead letter queue (DLQ.queuName).

We have this working OK, but we are missing the exception thrown, either the first one or the last one, we don't care (it'll probably be the same). This is something that can be done on other brokers (like WebLogic JMS), but I've been struggling with this for a while to no avail.

Does anybody know if this is something that can be configured or do I need to build a specific Mule exception handler or policy for ActiveMQ.

TIA, Martin

user627096
  • 11
  • 2

1 Answers1

1

That exception is lost in ActiveMQ at the moment (don't know about Mule) but it is reported to the log as error. It would make a good enhancement, remembering the string form of the exception in the ActiveMQConsumer and passing it back to the broker with the poison Ack that forces it to go to the DLQ. In that way, it could be remembered as a message property in the resulting DLQ message. How would you like to handle the exception, have it reported to a connection exception listener or have it recorded in the DLQ message?

gtully
  • 556
  • 4
  • 5
  • Hi, I wanted to preserve it as custom header/property of the DLQ message. Is there some policy interface that I can implement to treat the message before it is sent to the DLQ? – user627096 Feb 25 '11 at 04:09
  • Using a broker plugin, you can implement org.apache.activemq.broker.Broker#sendToDeadLetterQueue and make some modifications. There is an existing variant that discards messages, for the source is linked at the bottom of the refernece page. see: http://activemq.apache.org/message-redelivery-and-dlq-handling.html#MessageRedeliveryandDLQHandling-TheDiscardingDLQPlugin – gtully Feb 25 '11 at 09:47
  • I'll try that. So changes to the message (basically the new property) won't be lost when the tx is rollbacked? Do I need to store the transaction somewhere to later get it here or is it available somewhere? Thanks a lot. I have seen this plugin before but I thought that there might be something more straightforward. – user627096 Feb 25 '11 at 15:06
  • Have implemented the feature, the exception is now captured in a message property of the DLQ message, this will be in the upcoming ActiveMQ 5.5. Details in https://issues.apache.org/jira/browse/AMQ-3236 – gtully Mar 22 '11 at 13:52