首页 > 解决方案 > 使用骆驼文件语言

问题描述

我们正在尝试使用文件组件的 move、preMove 和 Error 选项。这是我们的目录结构

//root/child/ic/dir1/child1 //root/child/ic/dir1/child2

当从 child1 读取要处理的文件时,我们希望将其移动到 child1 中的 inprogress,然后在 //root/child/ic/dir1//processed 处处理

我们尝试了许多文件语言语法的组合,但似乎没有任何效果。这里有几个例子

对于 move/${date:now:yyyyMMdd}/${file:name} 日期组件永远不会将模式解析为真实日期,并且 file:name 也无法解析如何给出 ?move=../processed 以便文件上移一个目录到 //root/child/ic/ llly

我还想将转换后的文件移动到相对于 //root/child/ic/ 的文件夹中。我们将根文件夹设置在 ${user.home}/root/child/ic。由于我们有许多子文件夹并且我们希望转换后的文件相对于子文件夹保持相对路径,因此我们如何提供相对路径而无需对其进行硬编码。

标签: fileapache-camel

解决方案


 When we did the following in our consts file it worked.public static final String FILE_COMPONENT_CONFIG = "file:{xxx.agent.rootDir}}?" +
      "preMove={{xxx.agent.preMove}}&" +
      "move=${file:parent}/../{{xxx.agent.move}}/${file:onlyname.noext.single}_${date:now:yyyyMMdd-hhmmss}.${file:name.ext}&" +
      "moveFailed=${file:parent}/../{{xxxx.agent.moveFailed}}/${file:onlyname.noext.single}_${date:now:yyyyMMdd-hhmmss}.${file:name.ext}&" +
      "idempotent={{xxx.agent.idempotent}}&" +
      "idempotentRepository=#trackRepository&" +
      "delay=30000&" +
      "include={{xxxx.agent.include}}&" +
      "recursive=true&" +
      "minDepth=2&" +
      "antExclude={{xxxx.agent.exclude}}";

推荐阅读