Camel2.13配置file端点noop=true后文件仍被移动到.camel目录问题咨询
问题根因
noop=true未生效是URI参数解析逻辑导致的,不属于Camel 2.13版本的bug,也不存在noop=true生效时文件仍被移动到.camel的合法场景。
具体分析
- 你的配置中,占位符
sod.input.file.cmp.from本身已经携带了参数分隔符?和include参数,后续在端点URI中拼接的&readLock=none、&noop=true等参数,因Camel 2.13版本的占位符解析顺序和File组件的参数解析逻辑,没有被正确识别到FileEndpoint的配置中。 - 当
noop=true未被识别时,Camel File组件会使用默认的处理策略,将处理完成的文件移动到.camel归档目录,符合组件的默认行为。 - 你手动设置
GenericFileNoOpProcessStrategy后生效,也反向证明了noop=true配置未被正确加载——noop=true的核心作用就是自动将处理策略替换为GenericFileNoOpProcessStrategy。
验证方法
你可以通过以下代码确认参数是否被正确解析:
FileEndpoint ep = (FileEndpoint) getContext().getEndpoint("ref:cmpFilesEp"); // 输出noop配置的实际值,正常配置下应该返回true,你的场景会返回false System.out.println(ep.isNoop()); // 输出当前使用的处理策略类名,正常配置下应该是GenericFileNoOpProcessStrategy System.out.println(ep.getProcessStrategy().getClass().getName());
永久修复方案
二选一即可:
- 所有参数统一放在占位符中,修改properties配置:
sod.input.file.cmp.from = ${sfs}\\extracts\\eod?include=.*EF_CMP2_OPEN.*|.*EF_CMP6_OPEN.*&readLock=none&sendEmptyMessageWhenIdle=true&filter=#dateFileFilter&noop=true
对应端点配置简化为:
<endpoint id="cmpFilesEp" uri="file:${sod.input.file.cmp.from}"/>
- 路径和参数拆分,占位符仅保留纯路径:
sod.input.file.cmp.from = ${sfs}\\extracts\\eod
对应端点配置修改为:
<endpoint id="cmpFilesEp" uri="file:${sod.input.file.cmp.from}?include=.*EF_CMP2_OPEN.*|.*EF_CMP6_OPEN.*&readLock=none&sendEmptyMessageWhenIdle=true&filter=#dateFileFilter&noop=true"/>
内容的提问来源于stack exchange,提问作者Mykhaylo Adamovych
相关产品推荐
相关产品推荐

