camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: [DISCUSS] - Camel 2.0 - Easier Camel Spring Transaction configuration
Date Tue, 07 Apr 2009 07:27:39 GMT
Hi

Latest progress now is that I have introduced the *transacted* DSL
keyword in both Java DSL and Spring DSL.
Its capable of auto lookup in the registry for the transaction policy
so no need to wire it.

For instance in this Spring XML

        <route>
            <from uri="direct:okay"/>
            <transacted/>
            <setBody>
                <constant>Tiger in Action</constant>
            </setBody>
            <bean ref="bookService"/>
            <setBody>
                <constant>Elephant in Action</constant>
            </setBody>
            <bean ref="bookService"/>
        </route>

The <transacted/> will look for beans of type
org.apache.camel.spi.TransactedPolicy that you define in the XML like
this

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

And on top of that you dont have to setup the transacted error
handler, eg notice we dont have any errorHandlerRef in the route XML
at all.

So what you only *must* do for defining a route as transacted is to
add the *transacted* DSL keyword.


Next step in improvement would be to handle that the
PROPAGATION_REQUIRED bean is optional, so Camel can lookup and find
the PlatformManager and default to required itself. Just like the JMS
component can do with transacted=true URI option.







On Mon, Apr 6, 2009 at 1:56 PM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
> On Mon, Apr 6, 2009 at 10:12 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>> Hi
>>
>> Background is CAMEL-1475, however the ticket title is a bit misleading
>>
>> This morning I got Camel to be able to use transacted routes without
>> you have to remember to configure a transactedErrorHandler.
>> This makes it a bit easier to use transacted routes in Camel.
>>
>> So what you must do is use the *policy* DSL to define that this route
>> is transacted.
>> It still requires all the spring XML gobble to setup the TX manager
>> and all that verbose XML you cannot remember.
>> We can look at improving this later, want to keep the two of them
>> separated to not loose oversight.
>>
>> What I wants to discuss is that I think the *policy* DSL keyword is a
>> bit too loose. I would like it to be renamed to something that states
>> its transacted, eg
>> a) transacted
>> b) transaction
>> c) transactedPolicy
>> d) transactionPolicy
>>
>> As the JMS component have a special *transacted* URI option, I would
>> like the DSL to use same name as well.
>> So I am in favor of option A.
> I have worked a bit more on this. We keep the policy as is as it can
> be used for generic wrapping routes by an interceptor.
> We can use this for security stuff as well.
>
> I have instead added
> - transacted()
> - transacted(String ref)
> to the ProcessorDefinition so we in the Java DSL can indicate the
> route is transacted using a key word that states this than eg just
> policy.
> I am also working on being able to auto lookup the
> PROPAGATION_REQUIRED so you dont even have to specify a reference.
> Camel will
> just use the one found, if there are ONLY ONE TransactedPolicy bean
> defined in the registry.
>
> Next up is to be able to default to find the PlatformManager and just
> use a default REQUIRED policy so we dont even have to setup the
> PROPAGATION_REQUIRED bean in the XML. This will make it a bit easier
> to configure, then you just have to remember all the standard Spring
> TX XML stuff and then Camel can use it out of the box. Just you
> remember to add the *transacted* DSL in the route.
>
> PS: We could even consider adding a *transacted=true* pseudo URI
> option on DefaultComponent that will automatically added a
> *transacted* DSL to the route. Well just a whacky idea.
>
>
>
>
>
>
>>
>> CAMEL-1475 also hints some more improvements we can do with convention
>> over configuration, eg if there is only one SpringTransactionPolicy in
>> the XML then use that.
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Mime
View raw message