Apache Camel pollEnrich 没有复制所有文件

VG *_*gde 1 java activemq-classic jms apache-camel endpoint

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

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

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

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;
        }
Run Code Online (Sandbox Code Playgroud)

我也试过设置properties and onCompletions。仍然没有运气!我错过了什么aggregationStrategy吗?
如何成功复制所有文件和文件夹pollEnrich

小智 6

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

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();
Run Code Online (Sandbox Code Playgroud)

我希望它会对某人有所帮助。