Camel File组件:文件没有在本地磁盘上传输

kmbjn2e3  于 2023-06-29  发布在  Apache
关注(0)|答案(2)|浏览(181)

我是 Camel 的新手,我正在做一些非常基本的事情。尝试将文件从一个目录移动到另一个目录,不进行处理。

try{

   from("file:E:\\input").to("file:E:\\output");
}
catch (Exception e) {
   e.printStackTrace();
}

未捕获异常,文件路径为绝对路径。谁能帮我想想出了什么问题。
谢谢

jbose2ul

jbose2ul1#

请试试这个
从(“file://E:/input/?delete=true”).to(“file://E:/outputdir”)

ev7lccsx

ev7lccsx2#

我有这个蓝图 Camel 路线下面

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
             http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">

  <camelContext id="blueprint-bean-context" xmlns="http://camel.apache.org/schema/blueprint">
    <route id="WatchDirectoryRoute">
      <from uri="file://home/wagner/___inputdir/?delete=true"/>
      <to uri="file:///home/wagner/___outputdir?fileName=copy-of-${file:name}"/>
    </route>
  </camelContext>

</blueprint>

karaf.log显示路由正在监视目录

2023-06-28T18:41:58,253 | DEBUG | Camel (blueprint-bean-context) thread #39 - file://home/wagner/___inputdir/ | GenericFileConsumer              | 107 - org.apache.camel.camel-file - 3.20.6 | Took 0ms to poll: home/wagner/___inputdir
2023-06-28T18:41:58,754 | DEBUG | Camel (blueprint-bean-context) thread #39 - file://home/wagner/___inputdir/ | GenericFileConsumer              | 107 - org.apache.camel.camel-file - 3.20.6 | Took 0ms to poll: home/wagner/___inputdir

但是将文件放在/home/wagner/_inputdir中不会触发路由。
我的蓝图xml可能有什么问题?
为了补充信息,下面的蓝图工作正常

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <from uri="timer:test" />
            <to uri="log:test" />
        </route>
    </camelContext>

</blueprint>

   2023-06-28T18:54:25,757 | INFO  | Camel (camel-22) thread #40 - timer://test | test                             | 87 - org.apache.camel.camel-api - 3.20.6 | Exchange[ExchangePattern: InOnly, BodyType: null, Body: [Body is null]]
2023-06-28T18:54:26,756 | DEBUG | Camel (camel-22) thread #40 - timer://test | SendProcessor                    | 100 - org.apache.camel.camel-core-processor - 3.20.6 | >>>> log://test Exchange[]
2023-06-28T18:54:26,757 | INFO  | Camel (camel-22) thread #40 - timer://test | test                             | 87 - org.apache.camel.camel-api - 3.20.6 | Exchange[ExchangePattern: InOnly, BodyType: null, Body: [Body is null]]

相关问题