1

I want to provide transactions in my project. I have ESB with Spring and mySQL. When I send a request to register endpoint, user appears in database and this is good behavior. Then I try to force rollback by throwing RuntimeException and there is no action.

Is it possible to manage the transactions only in Spring?

<tx:annotation-driven transaction-manager="transactionManager" />

<tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="*" propagation="REQUIRED" rollback-for="RuntimeException"/>
        </tx:attributes>
</tx:advice>

<aop:config>
        <aop:pointcut id="register" expression="execution(* com.api.Register.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="register" />
</aop:config>

<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUrl" value="url" />
        <property name="username" value="username" />
        <property name="password" value="password" />
</bean>
<bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
</bean>
Mateusz
  • 61
  • 5
  • Which version of Mule are you using? – aled Oct 02 '19 at 22:59
  • Mule version is 3.9.0, Spring 4.1.9 – Mateusz Oct 03 '19 at 07:30
  • @aled what do you think? – Mateusz Oct 04 '19 at 14:03
  • I suspect the Spring transaction manager is independent from the transaction manager used by Mule 3. That is the case in Mule 4 for sure. – aled Oct 04 '19 at 14:09
  • So is it possible to manage transaction in Spring only? I have the following log in debug mode: `[org.mybatis.spring.transaction.SpringManagedTransaction] - JDBC Connection [MySQL Connector Java]* will not be managed by Spring* ` – Mateusz Oct 05 '19 at 09:07
  • That seems related to MyBatis transaction management, nothing to do with Mule 3. You'll have to check MyBatis documentation about that. – aled Oct 05 '19 at 12:41

0 Answers0