3
votes

I am using a MDB to process a JMS message. In case of an exception, I would ideally want to stamp a JMS message with the error detail as well (exception message) and allow it proceed to a dead letter queue (configured in Weblogic server).

In the catch block, I mutated the JMS Message object as follows

msg.clearProperties();
msg.setStringProperty("error", e.getMessage());

and threw a RuntimeException which marked the message consumption process as failed and hence it moved to a failed request queue (I configured Weblogic NOT to REDELIVER the message)

As per configuration, the message fails goes to the failed request queue - however the 'error' property was not included. Having read JMS 1.1 spec doc, it says that the a redelivered JMS message will have the 'original' content. In this case, I have forced Weblogic not to redeliver it - not sure why I cant see the custom property which I set on the message

Is this expected? If yes, any workarounds?

1

1 Answers

4
votes

It's because you rollback the transaction. You cannot roll back a JMS transaction and still make changes to the message.

What you should do is instead manually sending the modified message to an error queue in the same transaction. In that case, you cannot throw exceptions from your MDB.