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 4A258B235 for ; Sat, 14 Jan 2012 14:28:05 +0000 (UTC) Received: (qmail 20427 invoked by uid 500); 14 Jan 2012 14:28:04 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 20304 invoked by uid 500); 14 Jan 2012 14:28:04 -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 20296 invoked by uid 99); 14 Jan 2012 14:28:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Jan 2012 14:28:03 +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 (nike.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; Sat, 14 Jan 2012 14:27:57 +0000 Received: by lags15 with SMTP id s15so954677lag.32 for ; Sat, 14 Jan 2012 06:27:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=IdxAHB3PrVB+36upGIidMIaTVbVVqrZXw7w87DHP8ds=; b=MOvMjxvVJQpmp9r90dX9J3tAT1JZAfpeEFJJ53PMrIwQDK6ZZI1n+/z1VdA7/j0KrY XLvYkBKBUQgHBTgmOurldWukA8n0t73BcdM2q09HbMQCtqfFDtXrNnDD14uMbQGSU/Z3 GLSOLwipNvBtD/LiHUMOmdGEGYIjLPmunp7aU= Received: by 10.112.36.132 with SMTP id q4mr1277587lbj.3.1326551257241; Sat, 14 Jan 2012 06:27:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.95.141 with HTTP; Sat, 14 Jan 2012 06:27:16 -0800 (PST) In-Reply-To: <1326361548.10137.YahooMailNeo@web38008.mail.mud.yahoo.com> References: <1326335379939-5138775.post@n5.nabble.com> <1326361548.10137.YahooMailNeo@web38008.mail.mud.yahoo.com> From: Claus Ibsen Date: Sat, 14 Jan 2012 15:27:16 +0100 Message-ID: Subject: Re: Can I use RoutePolicySupport to ensure a ftp set of transfers is complete before return? 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 In Camel 2.9 we added a new option sendEmptyMessageWhenIdle which you can set to true. Then when Camel polls from the FTP server, and there are *no* files, then an empty message is sent out. Then you can just filter this message, and shutdown your application. This can also be done using a route policy, so you do not need to add a filter eip to your route etc. Just implement the logic in the route policy, where you detect the empty message, and do that you do in the halt processor. And then stop your application. On Thu, Jan 12, 2012 at 10:45 AM, David Wynter wro= te: > Hi, > > Tried several methods of trying to achieve this: > FTP download with one or many files ( wildcard fileName ) one shot, no po= lling and do not exit the thread until all files are downloaded (could be 1= 1K file or a hundred 1MB files). > > Claus suggested PollingConsumer but also stated "The Polling Consumer wil= l poll 1 file at a time" so not suitable for many files. > > So now I have this: > > =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 routeD.from(sourcePath); > =A0=A0 =A0 =A0 routeD.to(localPath+"?fileExist=3DOverride"); > =A0=A0 =A0 =A0 =A0HaltProcessor pHalt =3D new HaltProcessor(); > =A0=A0 =A0 =A0 =A0pHalt.setContext(camelContext); > =A0=A0 =A0 =A0 =A0routeD.routeId(sourcePath); > =A0=A0 =A0 =A0 pHalt.setRouteId(sourcePath); > =A0=A0 =A0 =A0 =A0routeD.process(pHalt); > =A0 =A0 =A0 =A0 =A0 =A0camelContext.addRouteDefinition(routeD); > > =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0camelContext.startRoute(routeD); > > > where the HaltProcessor has this: > > public void process(Exchange exchange) throws Exception { > if(context!=3Dnull && routeId !=3D null) { > =A0=A0 =A0 =A0 =A0// remove myself from the in flight registry so we can = stop this route without trouble > =A0=A0 =A0 =A0 =A0context.getInflightRepository().remove(exchange); > =A0=A0 =A0 =A0 =A0// stop this route > =A0=A0 =A0 =A0 =A0context.stopRoute(routeId); > } > } > > This still seems to exit before the files are completely downloaded. I wa= nt it to wait until they are complete. > > So will adding a PolicyRoute and using onExchangeDone allow me to interro= gate the ftp endpoint to know that it has for example found 24 files that m= atch the fileName with wildcards and that it has completed all of them? > > It is clear what onExchangeDone means in the context of a message like a = JMS etc. but not in the context of a file in the process of being downloade= d via ftp. > > thanks, > > David --=20 Claus Ibsen ----------------- 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/