The camel-jpa JpaTransactionManager does not work as expected with mixed transaction and rollback scenario

Solution Verified - Updated -

Issue

Default camel-jpa JpaTransactionManager does not work as expected with mixed transaction and rollback scenario.

camel route

    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route id="parent-route">
            <from id="route-timer" uri="timer:foo?repeatCount=1"/>
            <transacted id="transactionA"/>
            <log id="_log1" message=">>> call rollback-route"/>
            <to id="_to1" uri="direct:rollback"/>
            <log id="_log2" message=">>> call commit-route"/>
            <to id="_to2" uri="direct:commit"/>
            <log id="_log3" message="done"/>
        </route>
        <route id="rollback-route">
            <from id="_from1" uri="direct:rollback"/>
            <onException id="_onException1">
                <exception>java.lang.Exception</exception>
                <log id="_log4" message=">>> rollback-route's' onException block. mark rollback"/>
                <rollback id="rollbackA" markRollbackOnlyLast="true"/>
            </onException>
            <transacted id="transactionB" ref="PROPAGATION_MANDATORY"/>
            <process id="_process1" ref="myCarProcessor"/>
            <to id="_to3" uri="jpa:io.fabric8.quickstarts.camel.Car?usePersist=true"/>
            <throwException
                exceptionType="java.lang.IllegalArgumentException"
                id="_throwException1" message="Forced"/>
        </route>
        <route id="commit-route">
            <from id="_from2" uri="direct:commit"/>
            <onException id="_onException2">
                <exception>java.lang.Exception</exception>
                <log id="_log5" message=">>> commit-route's onException block"/>
            </onException>
            <transacted id="transactionC" ref="PROPAGATION_REQUIRES_NEW"/>
            <process id="_process2" ref="myBicycleProcessor"/>
            <to id="_to4" uri="jpa:io.fabric8.quickstarts.camel.Bicycle?usePersist=true"/>
        </route>

There is no data in DB.

Environment

  • Red Hat Fuse
    • 7.12
    • SpringBoot runtime

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content