【问题标题】:Apache Camel - not moving fileApache Camel - 不移动文件
【发布时间】:2015-05-06 17:51:51
【问题描述】:

我无法弄清楚我在这里做错了什么。我尝试了各种方法,包括绝对路径、相对路径、启用日志记录(这似乎也不起作用,使用 Main、使用 DefaultCamelContext、添加threadsleep,但我无法让骆驼将文件从一个文件夹移动到另一个文件夹。

这是我的代码:

package scratchpad;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.dataformat.beanio.BeanIODataFormat;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.main.Main;
import org.apache.camel.spi.DataFormat;

public class CamelMain {

    private static Main main;

    public static void main(String[] args) throws Exception {
        main = new Main();
        main.addRouteBuilder( new RouteBuilder() {

            @Override
            public void configure() throws Exception {
//              DataFormat format = new BeanIODataFormat(
//                      "org/apache/camel/dataformat/beanio/mappings.xml",
//                      "orderFile");


                System.out.println("starting route");
                // a route which uses the bean io data format to format a CSV data
                // to java objects
                from("file://input?noop=true&startingDirectoryMustExist=true")
                .to("file://output");               
            }
        });
        //main.run();
        main.start();
         Thread.sleep(5000);
         main.stop();


    }

}

有人能看出上面有什么问题吗?

谢谢

【问题讨论】:

  • 并且您已经创建了一个名为input 的目录,因为您告诉 Camel 这个目录必须存在。然后只需在该目录中放置一个文件。 Camel 将其复制到输出目录。但是您需要在 5 秒内完成此操作,因为那是您的睡眠时间。

标签: java apache-camel


【解决方案1】:

例如,您可以阅读 Camel in Action 这本书的免费第 1 章,因为它有一个从上到下覆盖的文件复制示例。

pdf可以在这里下载:http://manning.com/ibsen/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多