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','cmoulli...@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