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 65E1891CA for ; Fri, 20 Apr 2012 07:15:31 +0000 (UTC) Received: (qmail 540 invoked by uid 500); 20 Apr 2012 07:15:31 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 326 invoked by uid 500); 20 Apr 2012 07:15:30 -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 308 invoked by uid 99); 20 Apr 2012 07:15:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Apr 2012 07:15:30 +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.215.45 as permitted sender) Received: from [209.85.215.45] (HELO mail-lpp01m010-f45.google.com) (209.85.215.45) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Apr 2012 07:15:26 +0000 Received: by lahe6 with SMTP id e6so8471555lah.32 for ; Fri, 20 Apr 2012 00:15:04 -0700 (PDT) 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:content-transfer-encoding; bh=upYTch9vQFP168VPG4XXz8UK6+iwkwhUztYT2Z8n738=; b=pg8Fuiujrz8i5F9XDLhPizc9CSfOHlp4OHjrVl/SpjakRI50xBTAsvcSk/H9WVDY6/ 1X+1pES3ZAu6oJX0J2Vvbj5g3gjT9p3EFI8gHMto782XUI7sWGj6DOebpg1RLO50G2c9 2S1B/GpPK++xqwSkZjvP6Ft0PWWOQ/jWPY3BmIyYmPd5K2WJsAEJ7Z+AlaVzEaLrogzw 85VDgscQXwzdeHAI3EAfYfIj7bgf4rHfNz5NlLjXwx4FlnBzQGCtbCARU+6rgKtla5qS tkmiNhSAH9qYuJdfRrNse1yE9ZrUIrl6vdGWqc4xg8QciLbnnTPJEBVZthnRHYEHq1wl hzgg== Received: by 10.152.127.136 with SMTP id ng8mr4824931lab.16.1334906104677; Fri, 20 Apr 2012 00:15:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.75.130 with HTTP; Fri, 20 Apr 2012 00:14:44 -0700 (PDT) In-Reply-To: <0EDEDF2E-94C5-4DE8-9E5B-FB64EC464831@Gamesys.co.uk> References: <0EDEDF2E-94C5-4DE8-9E5B-FB64EC464831@Gamesys.co.uk> From: Claus Ibsen Date: Fri, 20 Apr 2012 09:14:44 +0200 Message-ID: Subject: Re: using filter inside when? To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi Have you seen this FAQ. http://camel.apache.org/why-can-i-not-use-when-or-otherwise-in-a-java-camel= -route.html Also if you put the predicate inside the filter as a parameter then it helps the DSL as well. filter( xxxx ) instead of filter().xxxx() On Thu, Apr 19, 2012 at 7:06 PM, Xuan Huang wrot= e: > Hi all, > > What I'm trying to do is to authenticate a message before sending it to b= e processed using message filter, so I have something like > > .filter().method(MyAuthenticator.class, "isAuthenticated") > > However in my route builder, I also route the messages based on their typ= es using choice. So for example I have > > from(IN_QUEUE).choice() > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.when(header(JMS_TYPE).isEqualTo("Type1")) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.to("bean:myBean?method=3DhandleMe= ssage") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.when(header(JMS_TYPE).isEqualTo("Type2")) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.to("bean:yourBean?method=3Dhandle= Message") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.otherwise().to("activemq:myqueue.in.DLQ") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.routeId("jms-my-route"); > > the filter seems to work when I put it before choice, like this > > from(IN_QUEUE) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0..filter().method(ClientAuthenticator.clas= s, "isAuthenticated") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.choice() > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.when(header(JMS_TYPE).isEqualTo("Type1")) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.to("bean:myBean?method=3DhandleMe= ssage") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.when(header(JMS_TYPE).isEqualTo("Type2")) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.to("bean:yourBean?method=3Dhandle= Message") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.otherwise().to("activemq:myqueue.in.DLQ") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.routeId("jms-my-route"); > > But I want to only authenticate Type1 messages, not Type2 messages. > > So I tried > > from(IN_QUEUE).choice() > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.when(header(JMS_TYPE).isEqualTo("Type1")) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.filter().method(ClientAuthenticat= or.class, "isAuthenticated") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.to("bean:myBean?method=3DhandleMe= ssage").end() > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.when(header(JMS_TYPE).isEqualTo("Type2")) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.to("bean:yourBean?method=3Dhandle= Message") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.otherwise().to("activemq:myqueue.in.DLQ") > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.routeId("jms-my-route"); > > But the second when clauses is not valid. > > Can I use filter inside when?If not, is there another solution? > > Thanks! > xuan > --=20 Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: cibsen@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/