简体   繁体   English

使用spring jee-jndi查找注入的JMS XA连接工厂的行为与在Weblogic 12c上@Resource注入不同

[英]A JMS XA connection factory injected using spring jee-jndi lookup behaves differently than @Resource injection on Weblogic 12c

I have an MDB application recently ported to Weblogic 12c. 我最近有一个MDB应用程序移植到Weblogic 12c。 I use spring 3.1 to inject datasource and jms resources however have found that delivery of message queues does not succeed (without error), appearing to not participate in the XA transaction although no rollback is evident. 我使用spring 3.1注入数据源和jms资源,但是发现消息队列的传递不会成功(没有错误),尽管没有明显的回滚,但似乎没有参与XA事务。 I have since created a test app to isolate the issue. 此后,我创建了一个测试应用程序来隔离问题。 This test app contains: 该测试应用包含:

  1. session timer bean putting message on testQueue1 会话计时器bean将消息放在testQueue1上
  2. MDB1 updating the datasource and moving message from testQueue1 to testQueue2. MDB1更新数据源并将消息从testQueue1移动到testQueue2。

My spring configuration: 我的弹簧配置:

<jee:jndi-lookup id="jdbcDS" expected-type="javax.sql.DataSource" jndi-name="jdbc/test_OraclePool" />
<jee:jndi-lookup id="jmsCF" jndi-name="jms/test_ConnectionFactory" />
<jee:jndi-lookup id="jmsTestQueue1" jndi-name="jms/testQueue1"/>
<jee:jndi-lookup id="jmsTestQueue2" jndi-name="jms/testQueue2"/>
<bean id="transactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager">
        <property name="transactionManagerName" value="javax.transaction.TransactionManager"/>
</bean>

The connection factory and queues reside in the same sub deployment and target the same JMS server on Weblogic 12c. 连接工厂和队列位于相同的子部署中,并且以Weblogic 12c上的相同JMS服务器为目标。

So I have found if I inject the connection factory through ejb @Resource injection everything works fine however for reasons outside of my control, changing our application to inject the connection factory is not an option. 因此,我发现如果我通过ejb @Resource injection注入连接工厂,则一切正常,但是由于无法控制的原因,将应用程序更改为注入连接工厂不是一种选择。 The other interesting difference is the concrete factory class returned by the container in each case varies: @Resource returns - weblogic.deployment.jms.PooledConnectionFactory Spring jndi injection - weblogic.jms.client.JMSXAConnectionFactory. 另一个有趣的区别是容器在每种情况下返回的具体工厂类都各不相同:@Resource返回-weblogic.deployment.jms.PooledConnectionFactory Spring jndi注入-weblogic.jms.client.JMSXAConnectionFactory。

Does anyone have any idea what, if anything, I am missing? 有谁知道我想念什么,如果有的话?

In the instance of Spring configuration you are doing straight JNDI lookup of JMS connection factory. 在Spring配置实例中,您将直接对JMS连接工厂进行JNDI查找。 When using @Resource WebLogic injects JMS wrapper around the same factory. 使用@Resource时,WebLogic会在同一工厂附近注入JMS包装器。 Among other things that wrapper takes care of automatic transaction enlistment(foreign JMS providers do not get enlisted automatically otherwise). 包装器负责自动事务登记(其他情况下,外国JMS提供程序不会自动登记)。 For more details look here: http://docs.oracle.com/cd/E24329_01/web.1211/e24387/j2ee.htm#JMSPG366 and here https://docs.oracle.com/cd/E24329_01/web.1211/e24387/interop.htm#JMSPG555 有关更多详细信息,请参见此处: http : //docs.oracle.com/cd/E24329_01/web.1211/e24387/j2ee.htm#JMSPG366和此处https://docs.oracle.com/cd/E24329_01/web.1211 /e24387/interop.htm#JMSPG555

Although WebLogic has had support for JMS Wrappers since at least version 8.1 there is no public API(last I checked anyways) to use those wrappers in Java, thus making it difficult to piggyback on them for libraries like Spring. 尽管WebLogic至少从8.1版开始就支持JMS Wrappers,但尚无公共API(无论如何我最后都检查过)在Java中使用这些包装器,因此,很难像Spring这样的库中使用它们。 There is an enhancement request for this created a few years back(bug 20062862), but you would need to ask Oracle where they are with it. 几年前创建了一个增强请求(错误20062862),但是您需要询问Oracle在哪里。

If not using wrappers for foreign JMS providers you need to deal with enlistment yourself, which is unfortunate. 如果不为外国JMS提供者使用包装器,那么您需要自己应对入伍,这是不幸的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM