You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Olivier.Roger" <ol...@bsb.com> on 2010/10/29 16:47:07 UTC

Throttler in a Choice ?

Hello Camel,

I am using Camel 2.4 and writting my first Java DSL route
I would like to translate the following route from Spring DSL:

		<choice>
			<when>
			    <simple>${header.JMSPriority} &lt; 5</simple>
                    <throttle maximumRequestsPerPeriod="50"
timePeriodMillis="60000">
                        <to ref="nsResolved" />
                    </throttle>
                </when>
                <otherwise>
                    <to ref="nsResolved" />
                </otherwise>
            </choice>

Here is what I did :

    @Override
    public void configure() throws Exception {
        from("direct:throttler.in")
            .choice()
                .when(simple("header.JMSPriority >= 5"))
                    .throttle(50).timePeriodMillis(60000)
                    .to("direct:nsResolved")
                    //.end()
                .otherwise()
                    .to("direct:nsResolved")
            .end();
    }

In both case I can use otherwise() because I dont have a ChoiceDefinition
object.
Like that I get a ThrottlerDefinition, which implements block, so I should
close is with end() I suppose. 
In that case I get a ProcessDefinition not a ChoiceDefinition.

Am I doing something wrong here ?

Thanks for your help,

Olivier
-- 
View this message in context: http://camel.465427.n5.nabble.com/Throttler-in-a-Choice-tp3242130p3242130.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Throttler in a Choice ?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah you can get such situations in the Java DSL. Java Generics is not
up for the task of a full fledged DSL.

In Camel 3.0 we should improve the throttle DSL to not require child
nodes and hence the Java DSL ought to work.

You can split the route into other routes and link using direct to
workaround this in Java DSL.

On Fri, Oct 29, 2010 at 4:47 PM, Olivier.Roger <ol...@bsb.com> wrote:
>
> Hello Camel,
>
> I am using Camel 2.4 and writting my first Java DSL route
> I would like to translate the following route from Spring DSL:
>
>                <choice>
>                        <when>
>                            <simple>${header.JMSPriority} &lt; 5</simple>
>                    <throttle maximumRequestsPerPeriod="50"
> timePeriodMillis="60000">
>                        <to ref="nsResolved" />
>                    </throttle>
>                </when>
>                <otherwise>
>                    <to ref="nsResolved" />
>                </otherwise>
>            </choice>
>
> Here is what I did :
>
>    @Override
>    public void configure() throws Exception {
>        from("direct:throttler.in")
>            .choice()
>                .when(simple("header.JMSPriority >= 5"))
>                    .throttle(50).timePeriodMillis(60000)
>                    .to("direct:nsResolved")
>                    //.end()
>                .otherwise()
>                    .to("direct:nsResolved")
>            .end();
>    }
>
> In both case I can use otherwise() because I dont have a ChoiceDefinition
> object.
> Like that I get a ThrottlerDefinition, which implements block, so I should
> close is with end() I suppose.
> In that case I get a ProcessDefinition not a ChoiceDefinition.
>
> Am I doing something wrong here ?
>
> Thanks for your help,
>
> Olivier
> --
> View this message in context: http://camel.465427.n5.nabble.com/Throttler-in-a-Choice-tp3242130p3242130.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/