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 7B0C2F950 for ; Wed, 3 Apr 2013 13:32:09 +0000 (UTC) Received: (qmail 52796 invoked by uid 500); 3 Apr 2013 13:32:09 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 52634 invoked by uid 500); 3 Apr 2013 13:32:05 -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 52600 invoked by uid 99); 3 Apr 2013 13:32:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Apr 2013 13:32:04 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cwolf.algo@gmail.com designates 209.85.212.46 as permitted sender) Received: from [209.85.212.46] (HELO mail-vb0-f46.google.com) (209.85.212.46) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Apr 2013 13:31:59 +0000 Received: by mail-vb0-f46.google.com with SMTP id 11so440904vbe.33 for ; Wed, 03 Apr 2013 06:31:38 -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=tEaw8sU91/8ghzxCaIn6bLcp2xIlssnZn2lkZjJBA+c=; b=O2m72+XvwzlBBEkHjhyhGDaeZeZZkW1ClWLHH/sLuGN0dQleGh9F47oPDx3FXV5zv1 iA7tr/015i7V1dl2xYAkZ3O70Y3h+S3bgn8GIkkiqwSiF7zznvJxM+1zILYCcD0ZVf54 EcVgQecmXZW0Hi4MlvAONT1h9Pme69nGeyf8MYpoL0Bd81bC1VN6u9hCgLwA4Ga9TW5G IfQvXmBy4QklaNvdC6lhnNtWqIeuxm1rxnQrVDWa8Ij2GWVxW6T6vfUaERklXIbYwrjP lKSmzo8qDKtjgKR2q1XtBdQrto2bgPRD3n+VYJIdj/CYObETPivxfPqLNBjpmbPs8DDj +/pg== MIME-Version: 1.0 X-Received: by 10.52.177.161 with SMTP id cr1mr1001082vdc.64.1364995898096; Wed, 03 Apr 2013 06:31:38 -0700 (PDT) Received: by 10.58.207.39 with HTTP; Wed, 3 Apr 2013 06:31:37 -0700 (PDT) In-Reply-To: References: Date: Wed, 3 Apr 2013 09:31:37 -0400 Message-ID: Subject: Re: It is possible with Camel to use dynamic consumer? **after context start** From: Chris Wolf To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org I actually was basing my current attempts based on what I read on that page. I thought if you used a ScheduledPollingConsumer, that it would loop for you and didn't need a while-loop. I will just try plain PollingConsumer in a while-loop. BTW, I found the ticket for dynamic URIs for FTP consumers: CAMEL-4596 Thanks, Chris On Wed, Apr 3, 2013 at 5:07 AM, Claus Ibsen wrote: > You may want to see a little about consumer template here > http://camel.apache.org/polling-consumer.html > > Notice the the consumer template polls one message at a time. > > If you want to "download all available files" you would need to run > the code in a while loop as the example on that link. > > Though you can also add a new route at runtime with the from uri > computed. And then stop and remove the route if not longer needed. > > > On Tue, Apr 2, 2013 at 9:36 PM, Chris Wolf wrote: >> May I have the ticket #? (so I can watch/follow) >> >> When you say, "use a java bean" - what do you mean? >> >> Instantiate the FTP component like? >> >> FtpComponent comp = new FtpComponent(context); >> @SuppressWarnings("unchecked") >> FtpEndpoint endpt = (FtpEndpoint) >> >> comp.createEndpoint("ftp://localhost/download?localWorkDirectory=/tmp/local/data&noop=true&username=fred&password=secret"); >> final FtpConsumer cons = (FtpConsumer) >> endpt.createConsumer(new Processor() { >> @Override >> public void process(Exchange exchange) >> throws Exception { >> System.out.printf("%s\n", >> exchange.toString()); >> } >> }); >> cons.setStartScheduler(true); >> comp.start(); >> endpt.start(); >> cons.start(); >> >> On Tue, Apr 2, 2013 at 11:03 AM, Claus Ibsen wrote: >>> Hi >>> >>> There is a ticket scheduled for Camel 3.0 to allow enrich and >>> pollEnrich to support "dynamic uris" like the recipient list can do. >>> >>> Though implementing this requires an API change and thus scheduled for 3.0. >>> >>> You can always use a java bean to consume from an dynamic computed >>> endpoint. For example using consumer template etc. >>> >>> For ftp endpoints you may want to set disconnect=true, to avoid having >>> the connection running for a longer period. >>> >>> >>> >>> >>> On Sun, Mar 31, 2013 at 10:08 PM, Chris Wolf wrote: >>>> Claus, >>>> >>>> You addressed the issue of "dynamic URIs for Consumers" back in July-2009: >>>> >>>> http://camel.465427.n5.nabble.com/Dynamic-consumers-with-Camel-td476433.html >>>> >>>> However, all those use-cases, except for maybe #4, web console, which >>>> I can't run all are about >>>> calculating the URI *before* the context is started. What I'm looking >>>> for is a way to create and insert >>>> or update a polling consumer's URI - at runtime - *after* the context >>>> is started. >>>> >>>> For example: >>>> >>>> from("direct:start") >>>> .beanRef("config") >>>> .convertBodyTo(Document.class) >>>> .setHeader("Ftp_URI").xquery( >>>> "concat('ftp://'" +...some more xpaths into the >>>> inbound config doc...), String.class) >>>> .pollEnrich(/* whoops! this is referenced at route >>>> setup time, not route runtime... - it won't work */) >>>> .to("log:..."); >>>> >>>> So the question, more generally, is is it possible to alter the route >>>> definition - at runtime? i.e. after the route/context are started? >>>> >>>> You sorted of hinted at this in that July-2009 posting when you said: >>>> >>>> "2) You can always stop, modify and start a route in Camel at runtime." >>>> >>>> I don't see how that would work since I would likely be attempting to >>>> modify the route at runtime >>>> from a bean method in the route - or are you suggesting one route >>>> stops/modifies another route? >>>> >>>> So the way I see it is - I would create the ftp route with a bogus URI >>>> and option "&startScheduler=false", >>>> on the ftp endpoint, or autoStart=false on the route. Then in >>>> *another* route - the "configurer" route, >>>> I guess, access the ftp route and reconfigure the endpoint with the >>>> real settings, then start it's poll scheduler (or start it's route). >>>> >>>> Something like that? Any easier, more direct way? >>>> >>>> Thanks, >>>> >>>> >>>> Chris >>> >>> >>> >>> -- >>> 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