Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-22498

Transaction rollback set in <doCatch> block does not work if "handled true" is set in the onException block

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • fuse-7.13-GA
    • fuse-7.11.1-GA
    • Camel
    • None
    • False
    • None
    • False
    • % %
    • Todo
    • Very Likely

      Since rollback is marked, it should be work even "handled true" is set in the onException block.

      camelContext

      	<bean class="sample.MyCarProcessor" id="myCarProcessor" />
      	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
      		<onException id="_onException1">
      			<exception>java.lang.Exception</exception>
      			<handled>
      				<constant>true</constant>
      			</handled>
      			<log id="_log4" message=">>> onException block. Set handled true" />
      		</onException>
      		<route id="parent-route">
      			<from id="route-timer" uri="timer:foo?repeatCount=1" />
      			<transacted id="transactionA" />
      			<doTry>
      				<process id="_process1" ref="myCarProcessor" />
      				<to uri="jpa:io.fabric8.quickstarts.camel.Car?usePersist=true" />
      				<throwException
      					exceptionType="java.lang.IllegalArgumentException"
      					id="_throwException1" message="Forced" />
      				<doCatch>
      					<exception>java.lang.IllegalArgumentException</exception>
      					<handled>
      						<constant>false</constant>
      					</handled>
      					<log id="_log3" message="doCatch block. mark rollback" />
      					<rollback id="rollbackA" markRollbackOnly="true" />
      				</doCatch>
      				<doFinally>
      					<log id="_log3" message="done" />
      				</doFinally>
      			</doTry>
      		</route>
      
      	</camelContext>
      

      console log

      09:44:29.585 [main] INFO  o.a.camel.spring.SpringCamelContext - Apache Camel 2.23.2.fuse-7_11_1-00015-redhat-00002 (CamelContext: MyCamel) started in 0.206 seconds
      09:44:29.596 [main] INFO  i.f.quickstarts.camel.Application - Started Application in 4.523 seconds (JVM running for 4.824)
      Hibernate: insert into car (name, id) values (?, ?)
      09:44:30.668 [Camel (MyCamel) thread #1 - timer://foo] INFO  parent-route - doCatch block. mark rollback
      09:44:30.668 [Camel (MyCamel) thread #1 - timer://foo] INFO  parent-route - done
      09:44:30.669 [Camel (MyCamel) thread #1 - timer://foo] WARN  o.a.c.processor.DefaultErrorHandler - Rollback (MessageId: ID-fedora-1703119468416-0-2 on ExchangeId: ID-fedora-1703119468416-0-1) due: Forced
      09:44:30.670 [Camel (MyCamel) thread #1 - timer://foo] INFO  parent-route - >>> onException block. Set handled true
      

      DB check

      sample=# select * from car;
       id |    name    
      ----+------------
        0 | broken car
      (1 row)
      

      Following query is used to create a test DB.

      CREATE DATABASE sample;
      create table car (
        id integer, 
        name varchar(10)
      );
      create table bicycle (
        id integer, 
        name varchar(10)
      );
      

              zfeng@redhat.com Zheng Feng
              rhn-support-hfuruich Hisao Furuichi
              Tomas Veskrna Tomas Veskrna
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: