We have what we believe is a fairly common XA use case:
However we also need a way to handle internal errors and poison messages. The control flow we have in mind is something like this:
Is this a good approach, should we do it differently? How can we do this with EJBs?
We're using EJB 3.1 on JBoss AS 7.2 / EAP 6.1, coding against Narayana directly is an option. The JDBC driver is ojdbc7-12.1.0.1 and the JMS RAR is MQ Series (don't know the version).
What you could do is to use the Java EE event mechanism to get a notification when your transaction fails and create a subsequent output message.
See
You need to use a new transaction to write to the out queue to avoid rolling back the message writing as well.
You will still have the message in the input queue which caused the exception, since the rollback will prevent the successfull consumption. You need to handle that separately, for example by the JMS provider.