Apache Camel pollEnrich 没有复制所有文件 [英] Apache Camel pollEnrich is not copying all the files

查看:32
本文介绍了Apache Camel pollEnrich 没有复制所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条骆驼路线,如下图所示

I've a camel route which looks like below

from("activemq:queue:upload" )
    .pollEnrich().simple("file:basePath/${header.ID}?noop=true&recursive=true")
    .aggregationStrategy(new ExampleAggregationStrategy()) 
    .timeout(2000) 
 .toD("ftp:${header.destinationURI}")

在我的文件系统 file:basePath/${header.ID} 中包含多个文件夹.执行上述路由时,只会将第一个文件夹中的第一个文件复制到 ftp 服务器.剩余的文件夹(带子文件夹)没有被复制到 ftp 服务器!

In my file system file:basePath/${header.ID} contains multiple folders. When above route is executed, only 1st file from the 1st folder will be copied to ftp server. Remaining folders(with subfolders) aren't getting copied to ftp server!

ExampleAggregationStrategy()类的aggregate()方法如下

@Override
        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
            String destinationURI = "populatedURI";

        oldExchange.setOut(newExchange.getIn());
        oldExchange.getOut().setHeader("ID",  oldExchange.getIn().getHeader("ID"));
        oldExchange.getOut().setHeader("destinationURI", destinationURI);
        oldExchange.setFromEndpoint(newExchange.getFromEndpoint());
        oldExchange.setFromRouteId(newExchange.getFromRouteId());

            return oldExchange;
        }

我也尝试过设置 properties 和 onCompletions.仍然没有运气!我在 aggregationStrategy 中遗漏了什么吗?
如何使用pollEnrich成功复制所有文件和文件夹?

I've tried setting properties and onCompletions as well. Still no luck ! Am I missing anything in aggregationStrategy ?
How to copy all the files and folders successfully using pollEnrich?

推荐答案

我知道这是一个老问题,但我遇到了类似的问题,我使用 loopDoWhile() 解决了它.这是我的路线:

I know it's an old question but I had similar problem and I solve it using loopDoWhile(). Here's my route:

from("direct:start")    
    .setProperty("StartDate", simple("${date:now:yyyy-MM-dd'T'HH-mm-ss}"))
    .to("direct:download");

from("direct:download")
    .loopDoWhile(body().isNotNull())
        .pollEnrich()
        .simple("sftp://{{remote.user}}@{{remote.url}}/{{remote.directory}}?password={{remote.password}}"
                + "&move=.done/${property.StartDate}"
                + "&localWorkDirectory=work/tmp"
                + "&autoCreate=false"
                + "&consumer.bridgeErrorHandler=true"
                + "&throwExceptionOnConnectFailed=true"
                + "&recursive=true"
        )
        .timeout(0)
        .choice()
            .when(body().isNotNull())
                .to("file:work/inbox/?fileName=${file:name}")
            .otherwise()
                .end()
    .end();

希望对大家有所帮助.

这篇关于Apache Camel pollEnrich 没有复制所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆