2

I think I am not getting something right with JMS and JTA. I am running in a Java EE container with all CMTs. Here is what I am doing:

  1. In an SLSB, write something to the database
  2. From the same method of the SLSB, post a message to a JMS queue
  3. An MDB in the same container listens to the JMS queue and picks up the message
  4. The MDB reads the database

The problem is, the MDB does not see the changes made to the database in step 1.

I verified that steps 1 and 2 happen inside a single XA transaction, as expected. My expectation is that a second XA transaction would start at step 3, after the first XA has been committed. But it seems that the MDB receives the message before the XA transaction that posted the message has been committed.

Is my expectation wrong and what I am seeing is normal?

I am running under JBoss 6. The SLSB is local. Both the SLSB and the MDB are in the same application.

4

2 回答 2

4

我发现了问题!我的 JMS 连接工厂不支持 XA。我为我的 JMS 连接工厂查找了 /XAConnectionFactory。尽管名称如此,但在 JBoss 中查找常规应用程序是错误的资源。还有一个 java:/XAConnectionFactory 也不起作用。正确的资源名称是 java:/JmsXA。我使用了它,一切都按预期工作。

感谢@strmqm 将我推向正确的方向。

于 2011-08-16T09:13:58.683 回答
1

我在使用 WebLogic 7 构建的应用程序中看到了一个概念上类似的问题。在 tx2(由 tx1 中的 JMS 发送启动)尝试读取它时,来自 tx1 的 DB 提交尚未完成。

问题在于我们的配置涉及一个带有非 XA db 连接(到 Oracle DB)的 WLS 7 XA 仿真层。这种风险是 XA 捷径的一部分。显然,如果我们一直使用真正的 XA 到数据库,那个洞就会关闭。从来没有结束过测试。

你说这是JBoss。他们有没有可能有一些类似的垫片绕过 XA 并给出同样令人惊讶的结果?

于 2011-08-15T21:23:22.750 回答