You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Alex Cali <al...@gmail.com> on 2015/04/17 15:02:59 UTC
Throtteling and dynamically changing MaxRequestsPerPeriod via Bean
I would like to change the MaxRequestsPerPeriod inside a Throttler.
I would like to use spring and having such a simple route, with some beans.
>>snip>>
<bean id="hello" class="example.HelloImpl"/>
<bean id="endMe" class="example.EndMe" />
<bean id="configurationSource" class="example.ConfigurationSource" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<throttle timePeriodMillis="1000">
<method ref="configurationSource"
method="getMessagesPerSecond"/>
<to uri="endMe"/>
</throttle>
</route>
</camelContext>
<<snip<<
But I cant get it to work, I will always get an error:
java.lang.IllegalArgumentException: MaxRequestsPerPeriod expression must be
provided on Throttle[bean{configurationSource, method=getMessagesPerSecond}
request per 1000 millis -> [To[endMe]]]
Using
<constant>3</constant> instead of the method expression works.
Did I misunderstood the concept of expressions?
Thx,
Alex
--
View this message in context: http://camel.465427.n5.nabble.com/Throtteling-and-dynamically-changing-MaxRequestsPerPeriod-via-Bean-tp5765952.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Throtteling and dynamically changing MaxRequestsPerPeriod via Bean
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Thanks for reporting I have reproduced the issue - its a bug when
using xml dsl. It works in java
https://issues.apache.org/jira/browse/CAMEL-8665
On Fri, Apr 17, 2015 at 3:50 PM, Alex Cali <al...@gmail.com> wrote:
> The bean should return a number > 0, the class is fairly simple:
>
>
> public class ConfigurationSource {
> private long messagesPerSecond = 10;
>
> public long getMessagesPerSecond() {
> return messagesPerSecond;
> }
>
> }
>
> Alex
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Throtteling-and-dynamically-changing-MaxRequestsPerPeriod-via-Bean-tp5765952p5765956.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/
Re: Throtteling and dynamically changing MaxRequestsPerPeriod via
Bean
Posted by Alex Cali <al...@gmail.com>.
The bean should return a number > 0, the class is fairly simple:
public class ConfigurationSource {
private long messagesPerSecond = 10;
public long getMessagesPerSecond() {
return messagesPerSecond;
}
}
Alex
--
View this message in context: http://camel.465427.n5.nabble.com/Throtteling-and-dynamically-changing-MaxRequestsPerPeriod-via-Bean-tp5765952p5765956.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Throtteling and dynamically changing MaxRequestsPerPeriod via Bean
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Are you sure the getMessagesPerSecond returns a number that is > 0 ?
On Fri, Apr 17, 2015 at 3:02 PM, Alex Cali <al...@gmail.com> wrote:
> I would like to change the MaxRequestsPerPeriod inside a Throttler.
>
> I would like to use spring and having such a simple route, with some beans.
>>>snip>>
> <bean id="hello" class="example.HelloImpl"/>
> <bean id="endMe" class="example.EndMe" />
> <bean id="configurationSource" class="example.ConfigurationSource" />
>
> <camelContext xmlns="http://camel.apache.org/schema/spring">
> <route>
> <from uri="direct:start"/>
> <throttle timePeriodMillis="1000">
> <method ref="configurationSource"
> method="getMessagesPerSecond"/>
> <to uri="endMe"/>
> </throttle>
> </route>
> </camelContext>
> <<snip<<
>
> But I cant get it to work, I will always get an error:
> java.lang.IllegalArgumentException: MaxRequestsPerPeriod expression must be
> provided on Throttle[bean{configurationSource, method=getMessagesPerSecond}
> request per 1000 millis -> [To[endMe]]]
>
> Using
> <constant>3</constant> instead of the method expression works.
>
> Did I misunderstood the concept of expressions?
>
> Thx,
> Alex
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Throtteling-and-dynamically-changing-MaxRequestsPerPeriod-via-Bean-tp5765952.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/