camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Problem of Intercept with When Condition
Date Fri, 16 Nov 2012 07:49:14 GMT
On Fri, Nov 16, 2012 at 8:01 AM, liugang <clevers594@gmail.com> wrote:
> Hi Willem:
>
> Yes, if you add the "when" close to the "intercept", there's no problem.
>
> But if add some more between them, for example:
>         Intercept().process(processor).when(....).to(...);
>
> Then you will see the problem.
>

The when *must* be right after the intercept!

> Please have a try.
>
> Thanks
> GangLiu
>
> -----Original Message-----
> From: Willem jiang [mailto:willem.jiang@gmail.com]
> Sent: Friday, November 16, 2012 2:53 PM
> To: users@camel.apache.org
> Subject: Re: Problem of Intercept with When Condition
>
> Hi,
>
> I just did a quick test on camel trunk, I cannot reproduce the error that you get.
> You can check out the unit test here[1].
>
> [1]https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteWhenTest.java
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>           http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>
>
>
>
>
> On Friday, November 16, 2012 at 2:07 PM, liugang wrote:
>
>> Hi All:
>>
>>
>> I have following codes:
>>
>> intercept().process(new Processor() {
>>
>>
>> public void process(Exchange
>> exchange) throws Exception {
>>
>> System.out.println("Intercept without condition");
>>
>> }
>>
>> }).when(simple("${in.body} ==
>> 'a'")).process(new Processor() {
>>
>>
>> public void process(Exchange
>> exchange) throws Exception {
>>
>> System.out.println("Intercept when body equals 'a'");
>>
>> }
>>
>> });
>>
>> from("timer:foo?repeatCount=1").setBody(constant("b")).process(
>>
>> new Processor() {
>>
>>
>> public void
>> process(Exchange exchange)
>>
>> throws Exception {
>>
>> System.out.println(exchange.getIn().getBody(
>>
>> String.class));
>>
>> }
>>
>> });
>>
>>
>> The result is:
>>
>>
>> Intercept without condition
>>
>> Intercept when body equals 'a'
>>
>> Intercept without condition
>>
>> Intercept when body equals 'a'
>>
>> b
>>
>>
>> But I think the correct one should be:
>>
>>
>> Intercept without condition
>>
>> Intercept without condition
>>
>> b
>>
>>
>> and if I move the when condition to next behind the intercept(), then it
>> works fine.
>>
>>
>> Does anybody can have a look, and check it's a Camel bug or not?
>>
>>
>> Thanks
>>
>> GangLiu
>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message