简体   繁体   English

Apache Camel-不移动文件

[英]Apache Camel - not moving file

I cannot figure out what I am doing wrong here. 我无法弄清楚我在做什么错。 I have tried all sorts of things, including absolute paths, relative, enabling logging (which also doesnt seem to be working, using Main, using DefaultCamelContext, adding threadsleep, but I cannot get camel to move a file from one folder to another. 我尝试了各种方法,包括绝对路径,相对路径,启用日志记录(使用Main,使用DefaultCamelContext并添加threadsleep似乎也不起作用,但是我无法让骆驼将文件从一个文件夹移动到另一个文件夹。

Here is my code: 这是我的代码:

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();


    }

}

Can someone spot anything wrong with the above? 有人可以发现以上内容有问题吗?

Thanks 谢谢

You can for example read from the free chapter 1 for the Camel in Action book, as it has a file copied example it covers from top to bottom. 例如,您可以从《骆驼在行动》一书的免费第1章中阅读,因为它有一个文件复制的示例,从上到下涵盖了该示例。

The pdf can be downloaded here: http://manning.com/ibsen/ pdf可以在这里下载: http : //manning.com/ibsen/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM