camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Can I use RoutePolicySupport to ensure a ftp set of transfers is complete before return?
Date Sat, 14 Jan 2012 14:27:16 GMT
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 <david_wynter@yahoo.com> wrote:
> Hi,
>
> Tried several methods of trying to achieve this:
> FTP download with one or many files ( wildcard fileName ) one shot, no polling 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 will poll 1 file
at a time" so not suitable for many files.
>
> So now I have this:
>
>                routeD.from(sourcePath);
>        routeD.to(localPath+"?fileExist=Override");
>         HaltProcessor pHalt = new HaltProcessor();
>         pHalt.setContext(camelContext);
>         routeD.routeId(sourcePath);
>        pHalt.setRouteId(sourcePath);
>         routeD.process(pHalt);
>            camelContext.addRouteDefinition(routeD);
>
>                 camelContext.startRoute(routeD);
>
>
> where the HaltProcessor has this:
>
> public void process(Exchange exchange) throws Exception {
> if(context!=null && routeId != null) {
>         // remove myself from the in flight registry so we can stop this route without
trouble
>         context.getInflightRepository().remove(exchange);
>         // stop this route
>         context.stopRoute(routeId);
> }
> }
>
> This still seems to exit before the files are completely downloaded. I want it to wait
until they are complete.
>
> So will adding a PolicyRoute and using onExchangeDone allow me to interrogate the ftp
endpoint to know that it has for example found 24 files that match 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 downloaded via ftp.
>
> thanks,
>
> David



-- 
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/

Mime
View raw message