Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43868DDC2 for ; Fri, 16 Nov 2012 08:46:56 +0000 (UTC) Received: (qmail 16713 invoked by uid 500); 16 Nov 2012 08:46:55 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 16678 invoked by uid 500); 16 Nov 2012 08:46:55 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 16655 invoked by uid 99); 16 Nov 2012 08:46:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2012 08:46:55 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 209.85.217.173 as permitted sender) Received: from [209.85.217.173] (HELO mail-lb0-f173.google.com) (209.85.217.173) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2012 08:46:50 +0000 Received: by mail-lb0-f173.google.com with SMTP id gj3so2268024lbb.32 for ; Fri, 16 Nov 2012 00:46:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Qv6TnE9iUY+j7gPKaCxfwwwlCQBvn/y1EP+DnDZ052A=; b=IlAUsClfHtNNUStXBAKlhzXNZ4psNb3QeoPuH/8yvSMk9E3FM71aEw02d81WuvsBvK tt/vUqBybiYdx+7Su/8Jw54FUCear/qI3IMSBrJMPjVpK/AEe2D9SAsOGeWAi157j7Gf u9/u17kDYjfBkNP7DSRAemBmLoZjS9wZgDYp/6ySEStklCCLgNNOrxo2aPu1ICIqLjy6 ZGj5/nMjLssfTBWunihRU2kS2zhojAn7ELqvji3UdycchkdZLkNFrxzun2BzGGxlkZsI QA44hTtIDnRnRuuXBR9RR+yzCw+zR8Ysw9TrCAvZbhpemktz9yhXRYBFoQZTBaCsEjyB Nb9w== Received: by 10.112.101.33 with SMTP id fd1mr806204lbb.27.1353055589436; Fri, 16 Nov 2012 00:46:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.103.129 with HTTP; Fri, 16 Nov 2012 00:46:09 -0800 (PST) In-Reply-To: <002701cdc3cf$658a2010$309e6030$@com> References: <002101cdc3c0$b11171a0$133454e0$@com> <6B580F1960F44F6C8C13B1BCF78C78C9@gmail.com> <002601cdc3c8$45167e70$cf437b50$@com> <002701cdc3cf$658a2010$309e6030$@com> From: Claus Ibsen Date: Fri, 16 Nov 2012 09:46:09 +0100 Message-ID: Subject: Re: Problem of Intercept with When Condition To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On Fri, Nov 16, 2012 at 8:52 AM, liugang wrote: > Hi Claus: > > Ah, ok, if so, then no problem. > But from the code, user can write everything what he wants, there's no any > hint to indicate that. May be it's better to improve it. > Thats not really possible as we have stretched how far you can take plain Java language as a DSL. And if you follow the documentation then you get it correct. And if you follow common sense. eg I want to intercept WHEN x == 5 > > Thanks > GangLiu > -----Original Message----- > From: Claus Ibsen [mailto:claus.ibsen@gmail.com] > Sent: Friday, November 16, 2012 3:49 PM > To: users@camel.apache.org > Subject: Re: Problem of Intercept with When Condition > > On Fri, Nov 16, 2012 at 8:01 AM, liugang 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 > -- 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