apache-camel - Apache-Camel 文件递归移动到同一子目录
问题描述
我目前有一条骆驼路线,它处理一个 zip 文件,然后将其移动到一个存储文件夹。
from(
file://importDir?recursive=true&preMove=processing&move=storage&moveFailed=error&include=.*\\.zip$
).bean(bean, "process")
在实际导入中,-Directory 是带有 zip 文件的子目录。我想在storage目录中也有相同的子目录,也可能在processing目录中。知道我是否可以使用路由和文件语言表达式来做到这一点?
解决方案
由于您已设置recursive=true
,因此无法设置move=storage
,因为这会导致循环。
例如:
- file.zip 被放置到
/importDir/some-folder/
- 文件使用者读取文件并将其发送给处理器
- 处理后将原始文件存储到
/importDir/some-folder/storage/
- 文件使用者递归地从
/importDir/some-folder/storage/
- 处理后的地方再放
/importDir/some-folder/storage/storage/
- 无限重复
现在您可以做的是设置move=.storage
将文件放置在上面的示例中/importDir/some-folder/.storage/
,文件使用者端点将忽略该文件。
/importDir/
更清洁的解决方案是使用例如将处理后的文件存储在外部move=/somepath/storage/${file:name}
。骆驼文档中有关此的更多信息
使用 ${file:name},目录结构在 storage 和 importDir 中应该保持不变。
推荐阅读
- html - 即使添加了元标记,html 表单也没有响应
- c# - 如何配置 Visual Studio Code 以从适用于 Linux 的 Windows 子系统 (WSL) 运行/调试 .NET (dotnet) Core?
- python - Python re.sub() 不会替换每个匹配项
- git - git结帐
或者 - reactjs - TypeError: react__WEBPACK_IMPORTED_MODULE_6___default.a.lazy 不是 react@16.5.2 的函数
- angular - Angular Kendo 是否支持服务器端分页?
- python - Django Wagtail 'expected string or bytes-like object' 错误
- pyspark - pyspark:按内部值的长度过滤行
- configure - 未找到 GnuTLS Libnettle 3.4
- azure - azure web 应用程序中根 url 中的 400 响应代码反咬