English 中文(简体)
Spring, XA and WebSphere
原标题:

I am trying to get XA transactions working in a Spring v3 application inside WebSphere v7.

My App Context reads:

<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"/>

I m referencing this article that says mix in the UOW txn manager and you ll be fine. But it doesn t work that way. Instead, in the following code, the message is destructively read and is not rolled back when an exception is thrown.

The transactional logic is (in 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)
  }
}

Can anyone advise how I can use WebSphere s JTA transaction manager with Spring?

问题回答

First of all, I would really like to see the code for readNextMessage as that may be the culprit.

Is the queue connection factory set up as an XA resource. You are trying to use JTA for transactions, so as far as I know you need to configure the message qcf accordingly.

You do not have to setup the JmsTemplate for transactions, as these are handled by the QueueConnectionFactory.

On a side note: if you are just dealing with mq, you can skip the UOW JTA provider and use transacted JMS sessions, which should work fine.





相关问题
Webspehere 6.1 and JNDI for something other than a Datasource

I was wondering: how does one go about configuring WAS if they want to store some confidential information that is not datasource, JMS or Mail related? I m looking more for an adhoc JNDI resource (a ...

申 诉 Server的服务器名称或管道和港口

我们愿确定并展示一个服务器和港口,即 Java的应用程序正在运行,它落后于一个代理网络服务器。 这意味着使ServerName()返回服务器......。

Signing SOAP messages using WSS4J

We need to sign a SOAP message with a certificate in Websphere 7. Currently we are looking at using WSS4J from Apache and are approaching this in the java code itself. Does anyone have any ...

JSP files in external directory

In my project, we allow customer to write customer specific logic in JSP pages and attach to our product. Right now after deploying .ear file customer copy the custom files under /WebContent/custom ...

RAD Websphere - EAR not picking up latest jar

I am using RAD 7.0. My web application works with a jar(contains the backend code for our application) which undergoes frequent changes. But whenever I replace the jar in the WebInf/lib folder of the ...

热门标签