You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Reji Mathews <co...@gmail.com> on 2020/09/24 20:38:45 UTC

JDBC transacted route // rollback not in-effect

Hello community

I have a transacted route with a jdbc operation. It has a
DataSourceTransactionManager bean in the application context which is set
with the datasource.

Though the log indicates rollback, the row inserted into the table wasn't
rolled back. Any suggestions would be helpful.


16:25:09.444 [http-nio-8888-exec-3] INFO
 com.company.camel.core.FlowManager - Integration is now started. Context
model <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<routes xmlns="http://camel.apache.org/schema/spring">
    <route customId="false" id="route2">
        <from uri="jetty:http://0.0.0.0:8081/txn?httpMethodRestrict=GET"/>
        <onException id="onException2" useOriginalMessage="true">
            <exception>java.lang.Exception</exception>
            <process id="process5"/>
            <choice id="choice2">
                <when id="when2">
                    <simple>${property.rollback_plans} != null</simple>
                    <to id="to4" uri="direct:rollback_plans_router"/>
                    <rollback id="rollback3" markRollbackOnly="true"/>
                </when>
                <otherwise id="otherwise2">
                    <log id="log4" loggingLevel="ERROR"
message="${exception}"/>
                    <to id="to5" pattern="InOnly"
uri="seda:exception_reporters?multipleConsumers=true"/>
                    <process id="process6"/>
                    <rollback id="rollback4" markRollbackOnly="true"/>
                </otherwise>
            </choice>
        </onException>
        <transacted id="transacted1">
            <log id="log5" message="Received http payload : ${body}"/>
            <to id="to6" uri="direct:5272a9f8-a718-3585-ac99-ab98b1f6007c"/>
        </transacted>
    </route>
<route customId="false" id="route1">
        <from uri="direct:5272a9f8-a718-3585-ac99-ab98b1f6007c"/>
        <setBody id="setBody1">
            <simple>insert into mydb.transaction_test (name) values ( '${
property.name}' )</simple>
        </setBody>
        <log id="log2" loggingLevel="INFO" message="Executing Sql Statement
: ${body}"/>
        <to id="to3"
uri="jdbc:fc9af189-1fe3-4d3b-8ac6-06a5a65dbe6a?resetAutoCommit=false"/>
        <removeHeaders id="removeHeaders1" pattern="CamelJdbc*"/>
        <throwException id="throwException1"/>
        <setBody id="setBody2">
            <expressionDefinition>language[simple:{ "status" : "ok"
 }]</expressionDefinition>
        </setBody>
        <log id="log3" loggingLevel="INFO" message="${body}"/>
    </route>
</routes>

16:25:18.052 [qtp5207044-102] INFO  route2 - Received http payload :
16:25:18.075 [qtp5207044-102] INFO  route1 - Executing Sql Statement :
insert into mydb.transaction_test (name) values ( 'matt' )
16:25:18.365 [qtp5207044-102] ERROR
com.company.camel.core.route.RouteErrorHandler - Error has occurred: custom
made
16:25:18.381 [qtp5207044-102] ERROR route1 - java.lang.Exception: custom
made
16:25:18.407 [Camel (ecdaaba8-cc6a-3312-ac13-fb2eaaf42d64) thread #3 -
seda://exception_reporters] INFO  route3 - creating entry in error table
{"error_message":"custom made","error_code":"APIC.8000"}
16:25:18.407 [Camel (ecdaaba8-cc6a-3312-ac13-fb2eaaf42d64) thread #4 -
seda://exception_reporters] INFO  route4 - creating entry in error queue
{"error_message":"custom made","error_code":"APIC.8000"}
16:25:18.417 [qtp5207044-102] WARN
 org.apache.camel.processor.DefaultErrorHandler - Rollback (MessageId:
ID-5CG7324CR4-1600979086161-1-10 on ExchangeId:
ID-5CG7324CR4-1600979086161-1-1) due: custom made

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor
                                               Elapsed (ms)
[route2            ] [route2            ] [jetty:
http://0.0.0.0:8081/txn?httpMethodRestrict=GET                          ] [
      912]
[route2            ] [transacted1       ] [transacted
                                             ] [         0]
[route2            ] [log5              ] [log
                                              ] [         5]
[route2            ] [to6               ]
[direct:5272a9f8-a718-3585-ac99-ab98b1f6007c
    ] [         0]
[route1            ] [setBody1          ] [setBody[simple{Simple: insert
into mydb.transaction_test (name) values ( '${pr] [         1]
[route1            ] [log2              ] [log
                                              ] [         1]
[route1            ] [to3               ]
[jdbc:fc9af189-1fe3-4d3b-8ac6-06a5a65dbe6a?resetAutoCommit=false
    ] [       280]
[route1            ] [throwException1   ]
[throwException[java.lang.Exception]
    ] [         0]
[route1            ] [process1          ] [Processor@0xac21e7
                                             ] [         3]
[route1            ] [choice1           ]
[when[simple{${property.rollback_plans} != null}]choice[]
   ] [        43]
[route1            ] [log1              ] [log
                                              ] [         1]
[route1            ] [to2               ]
[seda:exception_reporters?multipleConsumers=true
    ] [         1]
[route1            ] [process2          ] [Processor@0x1b1ce78
                                              ] [        27]
[route1            ] [rollback2         ] [rollback
                                             ] [         0]

16:25:18.510 [qtp5207044-102] WARN
 org.apache.camel.spring.spi.TransactionErrorHandler - Transaction rollback
(0x17180b2) redelivered(false) for (MessageId:
ID-5CG7324CR4-1600979086161-1-2 on ExchangeId:
ID-5CG7324CR4-1600979086161-1-1) due exchange was marked for rollbackOnly

Re: JDBC transacted route // rollback not in-effect

Posted by Zheng Feng <zf...@redhat.com>.
Hi,

What version of Camel do you use ? I think we have fixed the similar issue
with https://issues.apache.org/jira/browse/CAMEL-13529

On Fri, Sep 25, 2020 at 4:50 AM Reji Mathews <co...@gmail.com> wrote:

> Hello community
>
> I have a transacted route with a jdbc operation. It has a
> DataSourceTransactionManager bean in the application context which is set
> with the datasource.
>
> Though the log indicates rollback, the row inserted into the table wasn't
> rolled back. Any suggestions would be helpful.
>
>
> 16:25:09.444 [http-nio-8888-exec-3] INFO
>  com.company.camel.core.FlowManager - Integration is now started. Context
> model <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <routes xmlns="http://camel.apache.org/schema/spring">
>     <route customId="false" id="route2">
>         <from uri="jetty:http://0.0.0.0:8081/txn?httpMethodRestrict=GET"/>
>         <onException id="onException2" useOriginalMessage="true">
>             <exception>java.lang.Exception</exception>
>             <process id="process5"/>
>             <choice id="choice2">
>                 <when id="when2">
>                     <simple>${property.rollback_plans} != null</simple>
>                     <to id="to4" uri="direct:rollback_plans_router"/>
>                     <rollback id="rollback3" markRollbackOnly="true"/>
>                 </when>
>                 <otherwise id="otherwise2">
>                     <log id="log4" loggingLevel="ERROR"
> message="${exception}"/>
>                     <to id="to5" pattern="InOnly"
> uri="seda:exception_reporters?multipleConsumers=true"/>
>                     <process id="process6"/>
>                     <rollback id="rollback4" markRollbackOnly="true"/>
>                 </otherwise>
>             </choice>
>         </onException>
>         <transacted id="transacted1">
>             <log id="log5" message="Received http payload : ${body}"/>
>             <to id="to6"
> uri="direct:5272a9f8-a718-3585-ac99-ab98b1f6007c"/>
>         </transacted>
>     </route>
> <route customId="false" id="route1">
>         <from uri="direct:5272a9f8-a718-3585-ac99-ab98b1f6007c"/>
>         <setBody id="setBody1">
>             <simple>insert into mydb.transaction_test (name) values ( '${
> property.name}' )</simple>
>         </setBody>
>         <log id="log2" loggingLevel="INFO" message="Executing Sql Statement
> : ${body}"/>
>         <to id="to3"
> uri="jdbc:fc9af189-1fe3-4d3b-8ac6-06a5a65dbe6a?resetAutoCommit=false"/>
>         <removeHeaders id="removeHeaders1" pattern="CamelJdbc*"/>
>         <throwException id="throwException1"/>
>         <setBody id="setBody2">
>             <expressionDefinition>language[simple:{ "status" : "ok"
>  }]</expressionDefinition>
>         </setBody>
>         <log id="log3" loggingLevel="INFO" message="${body}"/>
>     </route>
> </routes>
>
> 16:25:18.052 [qtp5207044-102] INFO  route2 - Received http payload :
> 16:25:18.075 [qtp5207044-102] INFO  route1 - Executing Sql Statement :
> insert into mydb.transaction_test (name) values ( 'matt' )
> 16:25:18.365 [qtp5207044-102] ERROR
> com.company.camel.core.route.RouteErrorHandler - Error has occurred: custom
> made
> 16:25:18.381 [qtp5207044-102] ERROR route1 - java.lang.Exception: custom
> made
> 16:25:18.407 [Camel (ecdaaba8-cc6a-3312-ac13-fb2eaaf42d64) thread #3 -
> seda://exception_reporters] INFO  route3 - creating entry in error table
> {"error_message":"custom made","error_code":"APIC.8000"}
> 16:25:18.407 [Camel (ecdaaba8-cc6a-3312-ac13-fb2eaaf42d64) thread #4 -
> seda://exception_reporters] INFO  route4 - creating entry in error queue
> {"error_message":"custom made","error_code":"APIC.8000"}
> 16:25:18.417 [qtp5207044-102] WARN
>  org.apache.camel.processor.DefaultErrorHandler - Rollback (MessageId:
> ID-5CG7324CR4-1600979086161-1-10 on ExchangeId:
> ID-5CG7324CR4-1600979086161-1-1) due: custom made
>
> Message History
>
> ---------------------------------------------------------------------------------------------------------------------------------------
> RouteId              ProcessorId          Processor
>                                                Elapsed (ms)
> [route2            ] [route2            ] [jetty:
> http://0.0.0.0:8081/txn?httpMethodRestrict=GET                          ]
> [
>       912]
> [route2            ] [transacted1       ] [transacted
>                                              ] [         0]
> [route2            ] [log5              ] [log
>                                               ] [         5]
> [route2            ] [to6               ]
> [direct:5272a9f8-a718-3585-ac99-ab98b1f6007c
>     ] [         0]
> [route1            ] [setBody1          ] [setBody[simple{Simple: insert
> into mydb.transaction_test (name) values ( '${pr] [         1]
> [route1            ] [log2              ] [log
>                                               ] [         1]
> [route1            ] [to3               ]
> [jdbc:fc9af189-1fe3-4d3b-8ac6-06a5a65dbe6a?resetAutoCommit=false
>     ] [       280]
> [route1            ] [throwException1   ]
> [throwException[java.lang.Exception]
>     ] [         0]
> [route1            ] [process1          ] [Processor@0xac21e7
>                                              ] [         3]
> [route1            ] [choice1           ]
> [when[simple{${property.rollback_plans} != null}]choice[]
>    ] [        43]
> [route1            ] [log1              ] [log
>                                               ] [         1]
> [route1            ] [to2               ]
> [seda:exception_reporters?multipleConsumers=true
>     ] [         1]
> [route1            ] [process2          ] [Processor@0x1b1ce78
>                                               ] [        27]
> [route1            ] [rollback2         ] [rollback
>                                              ] [         0]
>
> 16:25:18.510 [qtp5207044-102] WARN
>  org.apache.camel.spring.spi.TransactionErrorHandler - Transaction rollback
> (0x17180b2) redelivered(false) for (MessageId:
> ID-5CG7324CR4-1600979086161-1-2 on ExchangeId:
> ID-5CG7324CR4-1600979086161-1-1) due exchange was marked for rollbackOnly
>