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

这一生的挚爱 提交于 2019-12-25 14:29:27

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/33957719/a-jms-xa-connection-factory-injected-using-spring-jee-jndi-lookup-behaves-differ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!