我试图让 XA 事务在 WebSphere v7 内的 Spring v3 应用程序中工作。
我的应用上下文内容如下:
<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 一起使用?