You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2011/03/22 16:59:28 UTC

Data not rollbacked from DB - camel-jdbc

Hi,

I have created a transactional route in camel where I use camel-jdbc
component but the data are not rollbacked from DB when an error
occurs. Is there something wrong in my config ?

Here is the config


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
       http://camel.apache.org/schema/spring/camel-spring.xsd
    ">

    <bean id="jdbcReportIncident"
class="com.fusesource.webinars.persistence.JdbcReportIncident"/>

    <bean id="required"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
    	<property name="transactionManager" ref="txManager"/>
    	<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
    </bean>

    <bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="reportdb"/>
    </bean>

    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">

        <route id="insert-from-file">
            <from uri="file://target/datainsert?moveFailed=failed"/>
            <transacted ref="required"/>
            <split>
                <tokenize token=","/>
                <setBody>
                    <simple>INSERT INTO REPORT.T_INCIDENT (INCIDENT_REF,

INCIDENT_DATE,GIVEN_NAME,FAMILY_NAME,SUMMARY,DETAILS,EMAIL,PHONE)
                        VALUES
('${body}','2011-03-21','Charles','Moulliard','Incident
Webinar-${body}','This is a
                        report incident for
webinar-001','cmoulliard@fusesource.com','+111 10 20 300')
                    </simple>
                </setBody>
                <log message=">>> SQL Query : ${body}"/>
                <to uri="jdbc:reportdb"/>
                <bean ref="jdbcReportIncident" method="generateError"/>
                <log message=">>> Result : ${body}"/>
            </split>
        </route>
    </camelContext>

    <bean id="reportdb"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
        <property name="url" value="jdbc:hsqldb:hsql://localhost/reportdb"/>
        <property name="username" value="sa"/>
        <property name="password" value=""/>
    </bean>

</beans>

Regards,

Charles Moulliard

Sr. Principal Solution Architect - FuseSource
Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard

Re: Data not rollbacked from DB - camel-jdbc

Posted by Charles Moulliard <cm...@gmail.com>.
Hi Christian,

Your are right, we should raise a ticket to decide what to do :
improve the component or update the wiki page to warn users.

BTW, If we decided to improve the component, than a decision should be
take about merging jdbc and sql component to keep only one !

Regards,

Charles Moulliard

Sr. Principal Solution Architect - FuseSource
Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard



On Wed, Mar 23, 2011 at 10:42 PM, Christian Müller
<ch...@gmail.com> wrote:
> Want we let it as it is? Or should we raise a JIRA for it and fix it?
> I would prefer to raise a JIRA for it...
>
> Christian
>
> On Wed, Mar 23, 2011 at 8:25 AM, Charles Moulliard <cm...@gmail.com>wrote:
>
>> Hi Willem,
>>
>> You confirm what I was suspected --> camel-jdbc is not a transactional
>> component.
>>
>> Regards,
>>
>> Charles
>>
>>
>>
>> On Wed, Mar 23, 2011 at 8:22 AM, Willem Jiang <wi...@gmail.com>
>> wrote:
>> > Hi Charles,
>> >
>> > I just went through the code of camel-jdbc and camel-sql.
>> > camel-sql is use the JdbcTemplate which can interact with the Spring
>> > transaction manage rightly.
>> > camel-jdbc just create a statment object base on the data source, that
>> could
>> > explain why the rollback doesn't work for you.
>> >
>> > Willem
>> > On 3/23/11 2:14 PM, Charles Moulliard wrote:
>> >>
>> >> I did that to simulate an error and check if the rollback will occur.
>> >>
>> >> REMARK : If I use the same camel routes but use SQL component instead of
>> >> JDBC, then it works !!!
>> >>
>> >> On 23/03/11 04:59, Willem Jiang wrote:
>> >>>
>> >>> Hi Charles,
>> >>>
>> >>> You route is a bit interesting, you just throw the exception after the
>> >>> exchange is sent to the camel-jdbc endpoint.
>> >>> Can you tell me why did you do that ?
>> >>>
>> >>> Willem
>> >>>
>> >>> On 3/22/11 11:59 PM, Charles Moulliard wrote:
>> >>>>
>> >>>> Hi,
>> >>>>
>> >>>> I have created a transactional route in camel where I use camel-jdbc
>> >>>> component but the data are not rollbacked from DB when an error
>> >>>> occurs. Is there something wrong in my config ?
>> >>>>
>> >>>> Here is the config
>> >>>>
>> >>>>
>> >>>> <beans xmlns="http://www.springframework.org/schema/beans"
>> >>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> >>>> xsi:schemaLocation="
>> >>>> http://www.springframework.org/schema/beans
>> >>>> http://www.springframework.org/schema/beans/spring-beans.xsd
>> >>>> http://camel.apache.org/schema/spring
>> >>>> http://camel.apache.org/schema/spring/camel-spring.xsd
>> >>>> ">
>> >>>>
>> >>>> <bean id="jdbcReportIncident"
>> >>>> class="com.fusesource.webinars.persistence.JdbcReportIncident"/>
>> >>>>
>> >>>> <bean id="required"
>> >>>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> >>>> <property name="transactionManager" ref="txManager"/>
>> >>>> <property name="propagationBehaviorName"
>> value="PROPAGATION_REQUIRED"/>
>> >>>> </bean>
>> >>>>
>> >>>> <bean id="txManager"
>> >>>>
>> >>>>
>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>> >>>>
>> >>>> <property name="dataSource" ref="reportdb"/>
>> >>>> </bean>
>> >>>>
>> >>>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring
>> ">
>> >>>>
>> >>>> <route id="insert-from-file">
>> >>>> <from uri="file://target/datainsert?moveFailed=failed"/>
>> >>>> <transacted ref="required"/>
>> >>>> <split>
>> >>>> <tokenize token=","/>
>> >>>> <setBody>
>> >>>> <simple>INSERT INTO REPORT.T_INCIDENT (INCIDENT_REF,
>> >>>>
>> >>>> INCIDENT_DATE,GIVEN_NAME,FAMILY_NAME,SUMMARY,DETAILS,EMAIL,PHONE)
>> >>>> VALUES
>> >>>> ('${body}','2011-03-21','Charles','Moulliard','Incident
>> >>>> Webinar-${body}','This is a
>> >>>> report incident for
>> >>>> webinar-001','cmoulliard@fusesource.com','+111 10 20 300')
>> >>>> </simple>
>> >>>> </setBody>
>> >>>> <log message=">>> SQL Query : ${body}"/>
>> >>>> <to uri="jdbc:reportdb"/>
>> >>>> <bean ref="jdbcReportIncident" method="generateError"/>
>> >>>> <log message=">>> Result : ${body}"/>
>> >>>> </split>
>> >>>> </route>
>> >>>> </camelContext>
>> >>>>
>> >>>> <bean id="reportdb"
>> >>>> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>> >>>> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
>> >>>> <property name="url" value="jdbc:hsqldb:hsql://localhost/reportdb"/>
>> >>>> <property name="username" value="sa"/>
>> >>>> <property name="password" value=""/>
>> >>>> </bean>
>> >>>>
>> >>>> </beans>
>> >>>>
>> >>>> Regards,
>> >>>>
>> >>>> Charles Moulliard
>> >>>>
>> >>>> Sr. Principal Solution Architect - FuseSource
>> >>>> Apache Committer
>> >>>>
>> >>>> Blog : http://cmoulliard.blogspot.com
>> >>>> Twitter : http://twitter.com/cmoulliard
>> >>>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
>> >>>> Skype: cmoulliard
>> >>>>
>> >>>
>> >>>
>> >>
>> >
>> >
>> > --
>> > Willem
>> > ----------------------------------
>> > FuseSource
>> > Web: http://www.fusesource.com
>> > Blog:    http://willemjiang.blogspot.com (English)
>> >         http://jnn.javaeye.com (Chinese)
>> > Twitter: willemjiang
>> >
>>
>

Re: Data not rollbacked from DB - camel-jdbc

Posted by Christian Müller <ch...@gmail.com>.
Want we let it as it is? Or should we raise a JIRA for it and fix it?
I would prefer to raise a JIRA for it...

Christian

On Wed, Mar 23, 2011 at 8:25 AM, Charles Moulliard <cm...@gmail.com>wrote:

> Hi Willem,
>
> You confirm what I was suspected --> camel-jdbc is not a transactional
> component.
>
> Regards,
>
> Charles
>
>
>
> On Wed, Mar 23, 2011 at 8:22 AM, Willem Jiang <wi...@gmail.com>
> wrote:
> > Hi Charles,
> >
> > I just went through the code of camel-jdbc and camel-sql.
> > camel-sql is use the JdbcTemplate which can interact with the Spring
> > transaction manage rightly.
> > camel-jdbc just create a statment object base on the data source, that
> could
> > explain why the rollback doesn't work for you.
> >
> > Willem
> > On 3/23/11 2:14 PM, Charles Moulliard wrote:
> >>
> >> I did that to simulate an error and check if the rollback will occur.
> >>
> >> REMARK : If I use the same camel routes but use SQL component instead of
> >> JDBC, then it works !!!
> >>
> >> On 23/03/11 04:59, Willem Jiang wrote:
> >>>
> >>> Hi Charles,
> >>>
> >>> You route is a bit interesting, you just throw the exception after the
> >>> exchange is sent to the camel-jdbc endpoint.
> >>> Can you tell me why did you do that ?
> >>>
> >>> Willem
> >>>
> >>> On 3/22/11 11:59 PM, Charles Moulliard wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> I have created a transactional route in camel where I use camel-jdbc
> >>>> component but the data are not rollbacked from DB when an error
> >>>> occurs. Is there something wrong in my config ?
> >>>>
> >>>> Here is the config
> >>>>
> >>>>
> >>>> <beans xmlns="http://www.springframework.org/schema/beans"
> >>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >>>> xsi:schemaLocation="
> >>>> http://www.springframework.org/schema/beans
> >>>> http://www.springframework.org/schema/beans/spring-beans.xsd
> >>>> http://camel.apache.org/schema/spring
> >>>> http://camel.apache.org/schema/spring/camel-spring.xsd
> >>>> ">
> >>>>
> >>>> <bean id="jdbcReportIncident"
> >>>> class="com.fusesource.webinars.persistence.JdbcReportIncident"/>
> >>>>
> >>>> <bean id="required"
> >>>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
> >>>> <property name="transactionManager" ref="txManager"/>
> >>>> <property name="propagationBehaviorName"
> value="PROPAGATION_REQUIRED"/>
> >>>> </bean>
> >>>>
> >>>> <bean id="txManager"
> >>>>
> >>>>
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> >>>>
> >>>> <property name="dataSource" ref="reportdb"/>
> >>>> </bean>
> >>>>
> >>>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring
> ">
> >>>>
> >>>> <route id="insert-from-file">
> >>>> <from uri="file://target/datainsert?moveFailed=failed"/>
> >>>> <transacted ref="required"/>
> >>>> <split>
> >>>> <tokenize token=","/>
> >>>> <setBody>
> >>>> <simple>INSERT INTO REPORT.T_INCIDENT (INCIDENT_REF,
> >>>>
> >>>> INCIDENT_DATE,GIVEN_NAME,FAMILY_NAME,SUMMARY,DETAILS,EMAIL,PHONE)
> >>>> VALUES
> >>>> ('${body}','2011-03-21','Charles','Moulliard','Incident
> >>>> Webinar-${body}','This is a
> >>>> report incident for
> >>>> webinar-001','cmoulliard@fusesource.com','+111 10 20 300')
> >>>> </simple>
> >>>> </setBody>
> >>>> <log message=">>> SQL Query : ${body}"/>
> >>>> <to uri="jdbc:reportdb"/>
> >>>> <bean ref="jdbcReportIncident" method="generateError"/>
> >>>> <log message=">>> Result : ${body}"/>
> >>>> </split>
> >>>> </route>
> >>>> </camelContext>
> >>>>
> >>>> <bean id="reportdb"
> >>>> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> >>>> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
> >>>> <property name="url" value="jdbc:hsqldb:hsql://localhost/reportdb"/>
> >>>> <property name="username" value="sa"/>
> >>>> <property name="password" value=""/>
> >>>> </bean>
> >>>>
> >>>> </beans>
> >>>>
> >>>> Regards,
> >>>>
> >>>> Charles Moulliard
> >>>>
> >>>> Sr. Principal Solution Architect - FuseSource
> >>>> Apache Committer
> >>>>
> >>>> Blog : http://cmoulliard.blogspot.com
> >>>> Twitter : http://twitter.com/cmoulliard
> >>>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
> >>>> Skype: cmoulliard
> >>>>
> >>>
> >>>
> >>
> >
> >
> > --
> > Willem
> > ----------------------------------
> > FuseSource
> > Web: http://www.fusesource.com
> > Blog:    http://willemjiang.blogspot.com (English)
> >         http://jnn.javaeye.com (Chinese)
> > Twitter: willemjiang
> >
>

Re: Data not rollbacked from DB - camel-jdbc

Posted by Charles Moulliard <cm...@gmail.com>.
Hi Willem,

You confirm what I was suspected --> camel-jdbc is not a transactional
component.

Regards,

Charles



On Wed, Mar 23, 2011 at 8:22 AM, Willem Jiang <wi...@gmail.com> wrote:
> Hi Charles,
>
> I just went through the code of camel-jdbc and camel-sql.
> camel-sql is use the JdbcTemplate which can interact with the Spring
> transaction manage rightly.
> camel-jdbc just create a statment object base on the data source, that could
> explain why the rollback doesn't work for you.
>
> Willem
> On 3/23/11 2:14 PM, Charles Moulliard wrote:
>>
>> I did that to simulate an error and check if the rollback will occur.
>>
>> REMARK : If I use the same camel routes but use SQL component instead of
>> JDBC, then it works !!!
>>
>> On 23/03/11 04:59, Willem Jiang wrote:
>>>
>>> Hi Charles,
>>>
>>> You route is a bit interesting, you just throw the exception after the
>>> exchange is sent to the camel-jdbc endpoint.
>>> Can you tell me why did you do that ?
>>>
>>> Willem
>>>
>>> On 3/22/11 11:59 PM, Charles Moulliard wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have created a transactional route in camel where I use camel-jdbc
>>>> component but the data are not rollbacked from DB when an error
>>>> occurs. Is there something wrong in my config ?
>>>>
>>>> Here is the config
>>>>
>>>>
>>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xsi:schemaLocation="
>>>> http://www.springframework.org/schema/beans
>>>> http://www.springframework.org/schema/beans/spring-beans.xsd
>>>> http://camel.apache.org/schema/spring
>>>> http://camel.apache.org/schema/spring/camel-spring.xsd
>>>> ">
>>>>
>>>> <bean id="jdbcReportIncident"
>>>> class="com.fusesource.webinars.persistence.JdbcReportIncident"/>
>>>>
>>>> <bean id="required"
>>>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>>> <property name="transactionManager" ref="txManager"/>
>>>> <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
>>>> </bean>
>>>>
>>>> <bean id="txManager"
>>>>
>>>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>>>>
>>>> <property name="dataSource" ref="reportdb"/>
>>>> </bean>
>>>>
>>>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>>>>
>>>> <route id="insert-from-file">
>>>> <from uri="file://target/datainsert?moveFailed=failed"/>
>>>> <transacted ref="required"/>
>>>> <split>
>>>> <tokenize token=","/>
>>>> <setBody>
>>>> <simple>INSERT INTO REPORT.T_INCIDENT (INCIDENT_REF,
>>>>
>>>> INCIDENT_DATE,GIVEN_NAME,FAMILY_NAME,SUMMARY,DETAILS,EMAIL,PHONE)
>>>> VALUES
>>>> ('${body}','2011-03-21','Charles','Moulliard','Incident
>>>> Webinar-${body}','This is a
>>>> report incident for
>>>> webinar-001','cmoulliard@fusesource.com','+111 10 20 300')
>>>> </simple>
>>>> </setBody>
>>>> <log message=">>> SQL Query : ${body}"/>
>>>> <to uri="jdbc:reportdb"/>
>>>> <bean ref="jdbcReportIncident" method="generateError"/>
>>>> <log message=">>> Result : ${body}"/>
>>>> </split>
>>>> </route>
>>>> </camelContext>
>>>>
>>>> <bean id="reportdb"
>>>> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>>>> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
>>>> <property name="url" value="jdbc:hsqldb:hsql://localhost/reportdb"/>
>>>> <property name="username" value="sa"/>
>>>> <property name="password" value=""/>
>>>> </bean>
>>>>
>>>> </beans>
>>>>
>>>> Regards,
>>>>
>>>> Charles Moulliard
>>>>
>>>> Sr. Principal Solution Architect - FuseSource
>>>> Apache Committer
>>>>
>>>> Blog : http://cmoulliard.blogspot.com
>>>> Twitter : http://twitter.com/cmoulliard
>>>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
>>>> Skype: cmoulliard
>>>>
>>>
>>>
>>
>
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
>

Re: Data not rollbacked from DB - camel-jdbc

Posted by Willem Jiang <wi...@gmail.com>.
Hi Charles,

I just went through the code of camel-jdbc and camel-sql.
camel-sql is use the JdbcTemplate which can interact with the Spring 
transaction manage rightly.
camel-jdbc just create a statment object base on the data source, that 
could explain why the rollback doesn't work for you.

Willem
On 3/23/11 2:14 PM, Charles Moulliard wrote:
> I did that to simulate an error and check if the rollback will occur.
>
> REMARK : If I use the same camel routes but use SQL component instead of
> JDBC, then it works !!!
>
> On 23/03/11 04:59, Willem Jiang wrote:
>> Hi Charles,
>>
>> You route is a bit interesting, you just throw the exception after the
>> exchange is sent to the camel-jdbc endpoint.
>> Can you tell me why did you do that ?
>>
>> Willem
>>
>> On 3/22/11 11:59 PM, Charles Moulliard wrote:
>>> Hi,
>>>
>>> I have created a transactional route in camel where I use camel-jdbc
>>> component but the data are not rollbacked from DB when an error
>>> occurs. Is there something wrong in my config ?
>>>
>>> Here is the config
>>>
>>>
>>> <beans xmlns="http://www.springframework.org/schema/beans"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="
>>> http://www.springframework.org/schema/beans
>>> http://www.springframework.org/schema/beans/spring-beans.xsd
>>> http://camel.apache.org/schema/spring
>>> http://camel.apache.org/schema/spring/camel-spring.xsd
>>> ">
>>>
>>> <bean id="jdbcReportIncident"
>>> class="com.fusesource.webinars.persistence.JdbcReportIncident"/>
>>>
>>> <bean id="required"
>>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>>> <property name="transactionManager" ref="txManager"/>
>>> <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
>>> </bean>
>>>
>>> <bean id="txManager"
>>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>>>
>>> <property name="dataSource" ref="reportdb"/>
>>> </bean>
>>>
>>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>>>
>>> <route id="insert-from-file">
>>> <from uri="file://target/datainsert?moveFailed=failed"/>
>>> <transacted ref="required"/>
>>> <split>
>>> <tokenize token=","/>
>>> <setBody>
>>> <simple>INSERT INTO REPORT.T_INCIDENT (INCIDENT_REF,
>>>
>>> INCIDENT_DATE,GIVEN_NAME,FAMILY_NAME,SUMMARY,DETAILS,EMAIL,PHONE)
>>> VALUES
>>> ('${body}','2011-03-21','Charles','Moulliard','Incident
>>> Webinar-${body}','This is a
>>> report incident for
>>> webinar-001','cmoulliard@fusesource.com','+111 10 20 300')
>>> </simple>
>>> </setBody>
>>> <log message=">>> SQL Query : ${body}"/>
>>> <to uri="jdbc:reportdb"/>
>>> <bean ref="jdbcReportIncident" method="generateError"/>
>>> <log message=">>> Result : ${body}"/>
>>> </split>
>>> </route>
>>> </camelContext>
>>>
>>> <bean id="reportdb"
>>> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>>> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
>>> <property name="url" value="jdbc:hsqldb:hsql://localhost/reportdb"/>
>>> <property name="username" value="sa"/>
>>> <property name="password" value=""/>
>>> </bean>
>>>
>>> </beans>
>>>
>>> Regards,
>>>
>>> Charles Moulliard
>>>
>>> Sr. Principal Solution Architect - FuseSource
>>> Apache Committer
>>>
>>> Blog : http://cmoulliard.blogspot.com
>>> Twitter : http://twitter.com/cmoulliard
>>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
>>> Skype: cmoulliard
>>>
>>
>>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Re: Data not rollbacked from DB - camel-jdbc

Posted by Charles Moulliard <cm...@gmail.com>.
I did that to simulate an error and check if the rollback will occur.

REMARK : If I use the same camel routes but use SQL component instead of 
JDBC, then it works !!!

On 23/03/11 04:59, Willem Jiang wrote:
> Hi Charles,
>
> You route is a bit interesting, you just throw the exception after the 
> exchange is sent to the camel-jdbc endpoint.
> Can you tell me why did you do that ?
>
> Willem
>
> On 3/22/11 11:59 PM, Charles Moulliard wrote:
>> Hi,
>>
>> I have created a transactional route in camel where I use camel-jdbc
>> component but the data are not rollbacked from DB when an error
>> occurs. Is there something wrong in my config ?
>>
>> Here is the config
>>
>>
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>         xsi:schemaLocation="
>>         http://www.springframework.org/schema/beans
>>         http://www.springframework.org/schema/beans/spring-beans.xsd
>>         http://camel.apache.org/schema/spring
>>         http://camel.apache.org/schema/spring/camel-spring.xsd
>>      ">
>>
>> <bean id="jdbcReportIncident"
>> class="com.fusesource.webinars.persistence.JdbcReportIncident"/>
>>
>> <bean id="required"
>> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>> <property name="transactionManager" ref="txManager"/>
>> <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
>> </bean>
>>
>> <bean id="txManager"
>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
>>
>> <property name="dataSource" ref="reportdb"/>
>> </bean>
>>
>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>>
>> <route id="insert-from-file">
>> <from uri="file://target/datainsert?moveFailed=failed"/>
>> <transacted ref="required"/>
>> <split>
>> <tokenize token=","/>
>> <setBody>
>> <simple>INSERT INTO REPORT.T_INCIDENT (INCIDENT_REF,
>>
>> INCIDENT_DATE,GIVEN_NAME,FAMILY_NAME,SUMMARY,DETAILS,EMAIL,PHONE)
>>                          VALUES
>> ('${body}','2011-03-21','Charles','Moulliard','Incident
>> Webinar-${body}','This is a
>>                          report incident for
>> webinar-001','cmoulliard@fusesource.com','+111 10 20 300')
>> </simple>
>> </setBody>
>> <log message=">>>  SQL Query : ${body}"/>
>> <to uri="jdbc:reportdb"/>
>> <bean ref="jdbcReportIncident" method="generateError"/>
>> <log message=">>>  Result : ${body}"/>
>> </split>
>> </route>
>> </camelContext>
>>
>> <bean id="reportdb"
>> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
>> <property name="url" value="jdbc:hsqldb:hsql://localhost/reportdb"/>
>> <property name="username" value="sa"/>
>> <property name="password" value=""/>
>> </bean>
>>
>> </beans>
>>
>> Regards,
>>
>> Charles Moulliard
>>
>> Sr. Principal Solution Architect - FuseSource
>> Apache Committer
>>
>> Blog : http://cmoulliard.blogspot.com
>> Twitter : http://twitter.com/cmoulliard
>> Linkedin : http://www.linkedin.com/in/charlesmoulliard
>> Skype: cmoulliard
>>
>
>

Re: Data not rollbacked from DB - camel-jdbc

Posted by Willem Jiang <wi...@gmail.com>.
Hi Charles,

You route is a bit interesting, you just throw the exception after the 
exchange is sent to the camel-jdbc endpoint.
Can you tell me why did you do that ?

Willem

On 3/22/11 11:59 PM, Charles Moulliard wrote:
> Hi,
>
> I have created a transactional route in camel where I use camel-jdbc
> component but the data are not rollbacked from DB when an error
> occurs. Is there something wrong in my config ?
>
> Here is the config
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="
>         http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans.xsd
>         http://camel.apache.org/schema/spring
>         http://camel.apache.org/schema/spring/camel-spring.xsd
>      ">
>
>      <bean id="jdbcReportIncident"
> class="com.fusesource.webinars.persistence.JdbcReportIncident"/>
>
>      <bean id="required"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>      	<property name="transactionManager" ref="txManager"/>
>      	<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/>
>      </bean>
>
>      <bean id="txManager"
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>          <property name="dataSource" ref="reportdb"/>
>      </bean>
>
>      <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>
>          <route id="insert-from-file">
>              <from uri="file://target/datainsert?moveFailed=failed"/>
>              <transacted ref="required"/>
>              <split>
>                  <tokenize token=","/>
>                  <setBody>
>                      <simple>INSERT INTO REPORT.T_INCIDENT (INCIDENT_REF,
>
> INCIDENT_DATE,GIVEN_NAME,FAMILY_NAME,SUMMARY,DETAILS,EMAIL,PHONE)
>                          VALUES
> ('${body}','2011-03-21','Charles','Moulliard','Incident
> Webinar-${body}','This is a
>                          report incident for
> webinar-001','cmoulliard@fusesource.com','+111 10 20 300')
>                      </simple>
>                  </setBody>
>                  <log message=">>>  SQL Query : ${body}"/>
>                  <to uri="jdbc:reportdb"/>
>                  <bean ref="jdbcReportIncident" method="generateError"/>
>                  <log message=">>>  Result : ${body}"/>
>              </split>
>          </route>
>      </camelContext>
>
>      <bean id="reportdb"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>          <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
>          <property name="url" value="jdbc:hsqldb:hsql://localhost/reportdb"/>
>          <property name="username" value="sa"/>
>          <property name="password" value=""/>
>      </bean>
>
> </beans>
>
> Regards,
>
> Charles Moulliard
>
> Sr. Principal Solution Architect - FuseSource
> Apache Committer
>
> Blog : http://cmoulliard.blogspot.com
> Twitter : http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard
> Skype: cmoulliard
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang