简体   繁体   中英

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. 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. I have since created a test app to isolate the issue. This test app contains:

  1. session timer bean putting message on testQueue1
  2. MDB1 updating the datasource and moving message from testQueue1 to 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.

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. 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.

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. When using @Resource WebLogic injects JMS wrapper around the same factory. Among other things that wrapper takes care of automatic transaction enlistment(foreign JMS providers do not get enlisted automatically otherwise). 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

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. 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.

If not using wrappers for foreign JMS providers you need to deal with enlistment yourself, which is unfortunate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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