[英]EJBs, XA transactions and error handling
We have what we believe is a fairly common XA use case: 我们认为这是一个相当常见的XA用例:
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?
我们如何使用EJB执行此操作?
We're using EJB 3.1 on JBoss AS 7.2 / EAP 6.1, coding against Narayana directly is an option. 我们在JBoss AS 7.2 / EAP 6.1上使用EJB 3.1,直接对Narayana进行编码是一种选择。 The JDBC driver is ojdbc7-12.1.0.1 and the JMS RAR is MQ Series (don't know the version).
JDBC驱动程序是ojdbc7-12.1.0.1,JMS RAR是MQ Series(不知道版本)。
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. 您可以做的是使用Java EE事件机制在事务失败时获取通知并创建后续输出消息。
See 看到
You need to use a new transaction to write to the out queue to avoid rolling back the message writing as well. 您需要使用新事务写入out队列,以避免回滚写入消息。
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.
您需要单独处理它,例如由JMS提供程序处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.