camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <>
Subject [jira] Commented: (CAMEL-1475) transactionErrorHandler should be able to wrap routes with default policy if no policy defined
Date Mon, 06 Apr 2009 11:12:34 GMT


Claus Ibsen commented on CAMEL-1475:

Okay got this baby working now
                    // marks this route as transacted, and we dont pass in any parameters
so we
                    // will auto lookup and use the Policy defined in the spring XML file
                    .setBody(constant("Tiger in Action")).beanRef("bookService")
                    .setBody(constant("Elephant in Action")).beanRef("bookService");

And with the Spring XML below Camel will lookup beans with the type {{org.apache.camel.spi.Policy}}
and if there are 1 policy defined it will use that as default.

    <!-- START SNIPPET: e1 -->
    <!-- datasource to the database -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
        <property name="url" value="jdbc:hsqldb:mem:camel"/>
        <property name="username" value="sa"/>
        <property name="password" value=""/>

    <!-- spring transaction manager -->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>

    <!-- policy for required transaction used in our Camel routes -->
    <bean id="PROPAGATION_REQUIRED" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <property name="transactionManager" ref="txManager"/>

    <!-- bean for book business logic -->
    <bean id="bookService" class="org.apache.camel.spring.interceptor.BookService">
        <property name="dataSource" ref="dataSource"/>
    <!-- END SNIPPET: e1 -->

Next step is to make it even easier, eg to be able to lookup the PlatformManager and if there
is 1 single defined use that one and use REQUIRED by default.
Then we can loose the PROPAGATION_REQUIRED bean.

> transactionErrorHandler should be able to wrap routes with default policy if no policy
> ----------------------------------------------------------------------------------------------
>                 Key: CAMEL-1475
>                 URL:
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core, camel-spring
>    Affects Versions: 1.6.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
> See TransactionalClientWithRollbackTest in camel-spring
> The {{.policy(required)}} is needed in the routes even though we have a global transaction
error handler with a default policy set:
> {code}
>                  errorHandler(transactionErrorHandler(required));
> {code}
> So Camel should fallback and use the global policy if the route itself does not have
a policy defined.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message