我试图让XA事务在WebSphere v7中的Spring v7应用程序中工作。
我的应用程序上下文是这样的:
<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管理器中混合,你会没事的。但不是这样的。相反,在下面的代码中,将对消息进行析构读取,并在抛出异常时回滚而不是。
事务逻辑(在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)
}
}有人能建议我如何在Spring中使用WebSphere的JTA事务管理器吗?
发布于 2013-11-19 07:45:15
首先,我非常希望看到readNextMessage的代码,因为这可能是罪魁祸首。
设置为XA资源的队列连接工厂。您正在尝试将JTA用于事务,因此据我所知,您需要相应地配置消息qcf。
您不必为事务设置JmsTemplate,因为这些事务是由QueueConnectionFactory处理的。
附带注意:如果您只是在处理mq,可以跳过UOW提供程序并使用事务JMS会话,这些会话应该可以正常工作。
https://stackoverflow.com/questions/5415276
复制相似问题