Spring、XA和WebSphere

Spring、XA和WebSphere,spring,websphere,xa,transactionmanager,Spring,Websphere,Xa,Transactionmanager,我试图让XA事务在WebSphereV7中的SpringV3应用程序中工作 我的应用程序上下文如下: <bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="jms/MQConnectionFactory"/> <property name="res

我试图让XA事务在WebSphereV7中的SpringV3应用程序中工作

我的应用程序上下文如下:

<bean id="jmsConnectionFactory" 
        class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jms/MQConnectionFactory"/>
    <property name="resourceRef" value="true"/>
</bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>

<jee:jndi-lookup id="myDB" jndi-name="jdbc/myDB"/>

<bean id="txManager"
    class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />

<tx:annotation-driven transaction-manager="txManager"/>
我引用的是UOW txn经理的话,你会没事的。但不是这样的。相反,在下面的代码中,消息以破坏性方式读取,并且在抛出异常时不会回滚

事务逻辑采用scala:

@Transactional(rollbackFor = Array(classOf[Throwable]))
def processNextMessage(category: String) = {
  val maybeMessage = readNextMessage(category) // <- this is a destructive read

  for (message <- maybeMessage) {
    // this is temporary code for testing
    throw new RuntimeException("blaaaaaah")
    // end temporary code

    // sendToQueue(message, queue)
    // writeToMessageStore(message)
  }
}

有人能告诉我如何将WebSphere的JTA事务管理器与Spring结合使用吗

首先,我很想看看readNextMessage的代码,因为这可能是罪魁祸首

队列连接工厂设置为XA资源。您正在尝试将JTA用于事务,据我所知,您需要相应地配置消息qcf

您不必为事务设置JmsTemplate,因为这些事务由QueueConnectionFactory处理


另请注意:如果您只是处理mq,那么可以跳过UOW JTA提供程序,使用事务化JMS会话,这应该可以正常工作。

jmsTemplate如何配置connectionFactory?是否设置了jmsTemplate的transactionManager属性?jmsTemplate上没有transactionManager属性。我读到注释方法意味着不需要显式注入。