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 AA946F5AE for ; Fri, 12 Apr 2013 14:43:34 +0000 (UTC) Received: (qmail 91268 invoked by uid 500); 12 Apr 2013 14:43:34 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 91237 invoked by uid 500); 12 Apr 2013 14:43:34 -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 91222 invoked by uid 99); 12 Apr 2013 14:43:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Apr 2013 14:43:34 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cn.okello@gmail.com designates 209.85.220.50 as permitted sender) Received: from [209.85.220.50] (HELO mail-pa0-f50.google.com) (209.85.220.50) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Apr 2013 14:43:28 +0000 Received: by mail-pa0-f50.google.com with SMTP id bg2so1478253pad.23 for ; Fri, 12 Apr 2013 07:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=EVBAjmM5DRkiwFMBhG7PbIOGSd5Eoatf9FLQPdfuFFg=; b=eorYMVr7IUy9xGvhDv13u2Te9Wq35O97lvaPu2KBeSbgUUZY2lu+C7HkggYng1PVra mIwz/OhIDxx1NcKH2TSvHeRpeUwBiDfHbXRxW7n74iFDEPeHwwpJ+9qxCzDqJLWseoVK o/WywHRPrgD7Hwubac8Wc9zx2/TOYaNInMZaHpiETLsqA7aP5a2/OZooh+8EY1Coqvb/ IA8xnzzha46RTvxEWlohRF5Xjs9QLFOUAEBU7pA7HgmJ2f8u1ARFshYrv+gBYsWIL5tm HCgldPqX9g3nWHm0aEN9vDkme7H+gGAjyvttOCAlqlh+nv7BKjda5FSpq+6kaR8IpHFi PFhg== MIME-Version: 1.0 X-Received: by 10.66.51.8 with SMTP id g8mr13547807pao.171.1365777788380; Fri, 12 Apr 2013 07:43:08 -0700 (PDT) Received: by 10.68.113.98 with HTTP; Fri, 12 Apr 2013 07:43:08 -0700 (PDT) In-Reply-To: References: Date: Fri, 12 Apr 2013 17:43:08 +0300 Message-ID: Subject: Re: Accessing CamelLoopIndex in route From: Okello Nelson To: users@camel.apache.org Content-Type: multipart/alternative; boundary=bcaec544ef58eb2eaa04da2aeb5a X-Virus-Checked: Checked by ClamAV on apache.org --bcaec544ef58eb2eaa04da2aeb5a Content-Type: text/plain; charset=ISO-8859-1 Hi Claus, I use the loop to retrieve the destinations for the content based router. The destinations are less than 10 but there's no way of telling in advance which ones they will be. So, I thought using a loop to dynamically build the destination makes more sense. I tried dynamic routes, and other options but they couldn't fit my usecase. Kind Regards, Okello Nelson. On Fri, Apr 12, 2013 at 5:34 PM, Claus Ibsen wrote: > Hi > > Well use the loop in the route if its sort make sense to have it > there, as it kinda stand out in the route, so people seeing the route, > can see its looping. > > Though if its not important, you can just do a for loop in the java > code in the processor. > > > > On Fri, Apr 12, 2013 at 4:30 PM, Okello Nelson > wrote: > > Hi Claus, > > > > Yes, it's the loop calling the process X times. I implemented it that > but I > > wasn't sure its the best way to do it. Thanks a lot. > > > > Kind Regards, > > Okello Nelson. > > > > > > On Fri, Apr 12, 2013 at 5:26 PM, Claus Ibsen > wrote: > > > >> Hi > >> > >> Do you mean its the loop that calls the process X times. If so yeah, > >> that is working correctly as designed. > >> > >> Calling the process() method of a org.apache.camel.Processor is > >> actually what the Camel routing engine does at runtime. In fact each > >> of these EIPs you may use in the routes, are implemented as a Camel > >> Processor. > >> > >> > >> > >> On Fri, Apr 12, 2013 at 3:57 PM, Okello Nelson > >> wrote: > >> > Hi Claus, > >> > > >> > Going through you comment again, I notice you've mentioned that the > >> > "configure()" method of the "RouteBuilder" is only executed once; when > >> the > >> > route is started. > >> > > >> > In my code, I'm executed this method once. The only method I'm calling > >> > repeatedly (for the length of the "fileTypes" array) is the > "process()" > >> > method of the "keFileTypeNameService" bean, which I assume is still > safe. > >> > > >> > Additional insight will be appreciated very much. > >> > > >> > Kind Regards, > >> > Okello Nelson. > >> > > >> > > >> > On Fri, Apr 12, 2013 at 4:52 PM, Okello Nelson > >> wrote: > >> > > >> >> Hi Claus, > >> >> > >> >> Thanks a lot for the insight. My objective was to create a content > based > >> >> router using information stored in an external file. I inject the > >> >> information into an array field using Spring, and so far the route > >> appears > >> >> to be working. > >> >> > >> >> But your explanation does give me something to think about, and I > guess > >> I > >> >> have to test my code further. I'll do so and post back my findings. > >> >> > >> >> Once again, thanks. > >> >> > >> >> Kind Regards, > >> >> Okello Nelson. > >> >> > >> >> > >> >> On Fri, Apr 12, 2013 at 11:28 AM, Claus Ibsen >> >wrote: > >> >> > >> >>> Hi > >> >>> > >> >>> The code in the configure() method of a RouteBuilder is only > executed > >> >>> once, when Camel startup and build the route from what you defined > in > >> >>> the configure method. > >> >>> > >> >>> So at runtime you need to use languages > >> >>> http://camel.apache.org/languages > >> >>> > >> >>> Or a java bean / camel processor / create your own predicate / etc. > to > >> >>> have this evaluation work. > >> >>> > >> >>> > >> >>> On Thu, Apr 11, 2013 at 3:17 PM, Okello Nelson > > >> >>> wrote: > >> >>> > Hi guys, > >> >>> > > >> >>> > I have the following route DSL: > >> >>> > > >> >>> > from("file:" + autoLoadBaseDir + "?move=.classified") > >> >>> > .loop(fileTypes.length) > >> >>> > .choice() > >> >>> > > >> >>> > > >> >>> > >> > .when(header("CamelFileName").contains(fileTypes[Integer.valueOf("${CamelLoopIndex}")])) > >> >>> > .to("file:" + classesBaseDir + "/" + > >> >>> > fileTypes[Integer.valueOf("${CamelLoopIndex}")]); > >> >>> > > >> >>> > I'm trying to use the loop index with an array to create a content > >> based > >> >>> > router. However, the "${CamelLoopIndex"} seems like its not being > >> >>> resolved. > >> >>> > Is there something that I'm doing wrong? Thanks in advance. > >> >>> > > >> >>> > Kind Regards, > >> >>> > Okello Nelson. > >> >>> > >> >>> > >> >>> > >> >>> -- > >> >>> 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 > >> >>> > >> >> > >> >> > >> >> > >> >> -- > >> >> Kind Regards, > >> >> Okello Nelson > >> >> +254 722 137 826 > >> >> cn.okello@gmail.com > >> >> > >> > > >> > > >> > > >> > -- > >> > Kind Regards, > >> > Okello Nelson > >> > +254 722 137 826 > >> > cn.okello@gmail.com > >> > >> > >> > >> -- > >> 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 > >> > > > > > > > > -- > > Kind Regards, > > Okello Nelson > > +254 722 137 826 > > cn.okello@gmail.com > > > > -- > 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 > -- Kind Regards, Okello Nelson +254 722 137 826 cn.okello@gmail.com --bcaec544ef58eb2eaa04da2aeb5a--