Spring MDP 中的 WebSphereUowTransactionManager 问题

发布于 2024-09-25 01:05:58 字数 6315 浏览 2 评论 0原文

我在使用 WebSphereUowTransactionManager 在 WebSphere 7.0 的 Spring 3.0.4 中设置 MDP 时遇到问题。

如果我不使用WebSphereUowTransactionManager,它就可以正常工作。如果没有它,我将不会对错误执行任何 XA 操作,所以我认为我确实需要它。

这是服务器上发生的情况:

[9/22/10 16:26:35:093 CDT] 00000070 SystemOut     O 16:26:35.093 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.t.j.WebSphereUowTransactionManager - Creating new transaction with name [jmsContainer]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[9/22/10 16:26:36:140 CDT] 00000070 SystemOut     O 16:26:36.140 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.j.l.DefaultMessageListenerContainer - Initiating transaction rollback on listener exception
java.lang.NullPointerException: null
    at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:571) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:354) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056) [org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:952) [org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61) [org.springframework.context.support-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:199) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.CJWorkItemImpl.run(CJWorkItemImpl.java:188) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) [com.ibm.ws.runtime.jar:na]
[9/22/10 16:26:36:140 CDT] 00000070 SystemOut     O 16:26:36.140 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.t.j.WebSphereUowTransactionManager - Initiating transaction rollback
[9/22/10 16:26:41:140 CDT] 00000070 SystemOut     O 16:26:41.140 [WorkManager.DefaultWorkManager : 4] WARN  o.s.j.l.DefaultMessageListenerContainer - Setup of JMS message listener invoker failed for destination 'queue://testQ?busName=WorkManagementBus' - trying to recover. Cause: null
java.lang.NullPointerException: null
    at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:571) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:354) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:952) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61) [org.springframework.context.support-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:199) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.CJWorkItemImpl.run(CJWorkItemImpl.java:188) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) [com.ibm.ws.runtime.jar:na]
[9/22/10 16:26:41:140 CDT] 00000070 SystemOut     O 16:26:41.140 [WorkManager.DefaultWorkManager : 4] INFO  o.s.j.l.DefaultMessageListenerContainer - Successfully refreshed JMS Connection

这是我的 applicationContext.xml 文件:

<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
<bean id="myTaskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
    <property name="workManagerName" value="wm/default" />
</bean>

<jee:jndi-lookup id="queue" jndi-name="jms/queue" resource-ref="true" proxy-interface="javax.jms.Queue"></jee:jndi-lookup>
<jee:jndi-lookup id="connectionFactory" jndi-name="jms/ConnectionFactory" resource-ref="true"></jee:jndi-lookup>

<bean id="jmsContainer"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"></property>
    <property name="destination" ref="queue"></property>
    <property name="messageListener" ref="testMessageListener"></property>

    <property name="taskExecutor" ref="myTaskExecutor"></property>
    <property name="transactionManager" ref="transactionManager"></property>
</bean>

<bean id="testMessageListener" class="navy.jmsey.TestMessageListener" />

我不明白为什么这不起作用。我想我正在做我应该做的一切。我按照 http://www.ibm.com/developerworks/ 中的指示操作websphere/techjournal/0609_alcott/0609_alcott.html

有人看到这个或看到我做错了什么吗?

谢谢。

更新: 我尝试过创建一个 EJB3 消息驱动 Bean,它按预期工作,出现异常时它会重新传递最多 5 次。问题是依赖注入和事务包含的语义变得更加复杂。我很确定这不是我想要的方式。

更新: 我请求 WebSphere 支持,但他们拒绝了我。正如预期的那样。

I am having trouble setting up a MDP in Spring 3.0.4 in WebSphere 7.0 using the WebSphereUowTransactionManager.

If I don't use WebSphereUowTransactionManager, it works just fine. Without it, I won't have any XA-action on errors, so I think I really need that.

Here is what happens on the server:

[9/22/10 16:26:35:093 CDT] 00000070 SystemOut     O 16:26:35.093 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.t.j.WebSphereUowTransactionManager - Creating new transaction with name [jmsContainer]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[9/22/10 16:26:36:140 CDT] 00000070 SystemOut     O 16:26:36.140 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.j.l.DefaultMessageListenerContainer - Initiating transaction rollback on listener exception
java.lang.NullPointerException: null
    at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:571) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:354) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056) [org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:952) [org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61) [org.springframework.context.support-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:199) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.CJWorkItemImpl.run(CJWorkItemImpl.java:188) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) [com.ibm.ws.runtime.jar:na]
[9/22/10 16:26:36:140 CDT] 00000070 SystemOut     O 16:26:36.140 [WorkManager.DefaultWorkManager : 4] DEBUG o.s.t.j.WebSphereUowTransactionManager - Initiating transaction rollback
[9/22/10 16:26:41:140 CDT] 00000070 SystemOut     O 16:26:41.140 [WorkManager.DefaultWorkManager : 4] WARN  o.s.j.l.DefaultMessageListenerContainer - Setup of JMS message listener invoker failed for destination 'queue://testQ?busName=WorkManagementBus' - trying to recover. Cause: null
java.lang.NullPointerException: null
    at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:571) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:354) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:952) ~[org.springframework.jms-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61) [org.springframework.context.support-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:199) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.asynchbeans.CJWorkItemImpl.run(CJWorkItemImpl.java:188) [com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) [com.ibm.ws.runtime.jar:na]
[9/22/10 16:26:41:140 CDT] 00000070 SystemOut     O 16:26:41.140 [WorkManager.DefaultWorkManager : 4] INFO  o.s.j.l.DefaultMessageListenerContainer - Successfully refreshed JMS Connection

Here is my applicationContext.xml file:

<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />
<bean id="myTaskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
    <property name="workManagerName" value="wm/default" />
</bean>

<jee:jndi-lookup id="queue" jndi-name="jms/queue" resource-ref="true" proxy-interface="javax.jms.Queue"></jee:jndi-lookup>
<jee:jndi-lookup id="connectionFactory" jndi-name="jms/ConnectionFactory" resource-ref="true"></jee:jndi-lookup>

<bean id="jmsContainer"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"></property>
    <property name="destination" ref="queue"></property>
    <property name="messageListener" ref="testMessageListener"></property>

    <property name="taskExecutor" ref="myTaskExecutor"></property>
    <property name="transactionManager" ref="transactionManager"></property>
</bean>

<bean id="testMessageListener" class="navy.jmsey.TestMessageListener" />

I can't figure out why this isn't working. I think I'm doing everything I'm supposed to. I followed the directions in http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html.

Anyone seen this or see what I'm doing wrong?

Thanks.

Update:
I've tried doing a EJB3 Message-driven Bean and that works as expected, on exception it gets redelivered up to 5 times. The problem with that, is the semantics for dependency injection and transaction containment just got more complicated. I'm pretty sure this isn't how I want to go.

Update:
I asked WebSphere support, but they turned me away. As expected.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦忆晨望 2024-10-02 01:05:58

这里似乎有一个 JIRA。

来设法使其正常工作。

   commitIfNecessary(session, message); // line 354

替换

   commitIfNecessary(sessionToUse, message); 

该人表示,她通过在 AbstractMessageListenerContainer.java 类中

It seems there is a JIRA on this here.

The person says she managed to get it working by replacing

   commitIfNecessary(session, message); // line 354

with

   commitIfNecessary(sessionToUse, message); 

in the AbstractMessageListenerContainer.java class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文