0

I am planning on using the Mybatis as the ORM tool for my application, before I dive deep into the configuration, i'd like to know if there is a way I can do JMS + Mybatis into the same transaction(Like XA transaction or two phase commit)? If not, does spring JDBC support the above case?

I've looked up a few answers in the SO, but have not got a concrete answer to Mybatis related.

Referred:

Spring Transaction Synchonization of JDBC and JMS

IBM MQManager as XA Transaction Manager with Spring-jms and Spring-tx

Community
  • 1
  • 1
Zeus
  • 6,386
  • 6
  • 54
  • 89

1 Answers1

1

Yes it must be. I have experience with hibernate and JMS(spring-jms) but not with JMS and mybatis. But here is some code example that could help in your case.

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>

    <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    .....
    <property name="transactionManager" ref="transactionManager"/>
    </bean>

This sorts out JTA participation for JMS. Read here for Mybatis inclusion in JTA transaction.

<jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/DBDS"/>

<bean id="myBatisSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">    
 ....
  <property name="dataSource" ref="dataSource" /> 
  <property name="transactionFactory">  
  <bean class="org.apache.ibatis.transaction.managed.ManagedTransactionFactory" />  
  </property>
</bean>
Rohit
  • 2,132
  • 1
  • 15
  • 24