Apache camel Camel ftp使用者在启动时忽略幂等文件存储库
我创建了一个使用ftp的路由:Apache camel Camel ftp使用者在启动时忽略幂等文件存储库,apache-camel,Apache Camel,我创建了一个使用ftp的路由: private RouteDefinition ftpRouteOcs() { IdempotentRepository<String> fileRep = FileIdempotentRepository.fileIdempotentRepository(new File("./downLoadedOcs"), A_MILLION, TEN_MB); // from endpoint FtpEndpoint<?>
private RouteDefinition ftpRouteOcs() {
IdempotentRepository<String> fileRep = FileIdempotentRepository.fileIdempotentRepository(new File("./downLoadedOcs"), A_MILLION, TEN_MB);
// from endpoint
FtpEndpoint<?> ftpEndpoint = getContext().getEndpoint(config.ftpUrlOcs(), FtpEndpoint.class);
ftpEndpoint.setIdempotentKey("${file:name}");
ftpEndpoint.setIdempotentRepository(fileRep);
ftpEndpoint.getConfiguration().setBinary(true);
//important!
ftpEndpoint.getConfiguration().setStepwise(false);
// no write or move operations - read only, set idempotent to true
ftpEndpoint.setNoop(true);
// only include files that match pattern
ftpEndpoint.setInclude(OCS_FILE_FILTER_PATTERN);
// fetch 1000 files in one poll...
ftpEndpoint.setMaxMessagesPerPoll(FTP_MAX_FILES_PER_POLL);
// but sort ALL files before...
ftpEndpoint.setEagerMaxMessagesPerPoll(false);
// ...by file name
ftpEndpoint.setSortBy("file:name");
// to endpoint
FileEndpoint fileEndpoint = getContext().getEndpoint("file:" + config.ftpTargetOcs(), FileEndpoint.class);
// mark finished downloads
fileEndpoint.setDoneFileName("${file:name}.done");
// ignore if exist
fileEndpoint.setFileExist(GenericFileExist.Ignore);
return from(ftpEndpoint).to(fileEndpoint).routeId(RouteIds.ftpOcs.name());
}
专用路由定义ftpRouteOcs(){
IdempotentRepository fileRep=FileIdempotentRepository.FileIdempotentRepository(新文件(“./downLoadedOcs”),一百万,十兆字节;
//从端点
FtpEndpoint FtpEndpoint=getContext().getEndpoint(config.ftpUrlOcs(),FtpEndpoint.class);
setIdempotentKey(${file:name});
ftpEndpoint.setIdempotentRepository(fileRep);
ftpEndpoint.getConfiguration().setBinary(true);
//重要!
ftpEndpoint.getConfiguration().setStepwise(false);
//无写入或移动操作-只读,将幂等项设置为true
ftpEndpoint.setNoop(真);
//仅包括与模式匹配的文件
ftpEndpoint.setInclude(OCS_文件_过滤器_模式);
//在一次轮询中获取1000个文件。。。
ftpEndpoint.setMaxMessagesPerPoll(每次轮询的最大文件数);
//但是在。。。
ftpEndpoint.setWangerMaxMessagesPerPoll(false);
//…按文件名
ftpEndpoint.setSortBy(“文件名”);
//终止
FileEndpoint FileEndpoint=getContext().getEndpoint(“文件:+config.ftpTargetOcs(),FileEndpoint.class”);
//标记已完成下载
fileEndpoint.setDoneFileName(“${file:name}.done”);
//忽略(如果存在)
fileEndpoint.setFileExist(GenericFileExist.Ignore);
从(ftpEndpoint).to(fileEndpoint.routeId)(RouteIds.ftpOcs.name())返回;
}
如您所见,我正在使用File幂等存储库。该文件创建得很好,下载的每个文件都被添加到该文件中-我得到所有相关的调试输出。问题是重新启动后,所有文件都会再次下载-存储库将被忽略。该文件仍然存在,并且在每次运行时,该文件都会使用相同的数据进行更新(创建日期保持不变,更改日期更新)。
那么我的设置有什么问题呢?克劳斯·易卜生在邮件列表中回答() 解决方法就是添加
fileRep.start();
因此,必须显式启动存储库