camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
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

    [ https://issues.apache.org/activemq/browse/CAMEL-1475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=51047#action_51047
] 

Claus Ibsen commented on CAMEL-1475:
------------------------------------

Okay got this baby working now
{code:java}
                from("direct:okay")
                    // 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
                    .transacted()
                    .setBody(constant("Tiger in Action")).beanRef("bookService")
                    .setBody(constant("Elephant in Action")).beanRef("bookService");
{code}

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.

{code:xml}
    <!-- 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=""/>
    </bean>

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

    <!-- 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>

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

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
defined
> ----------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-1475
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1475
>             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.


Mime
View raw message