首页 文章

如何使用apache camel复制文件

提问于
浏览
1
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class ReadFileExample {
public static void main(String [] args) throws Exception{
    System.out.println("trying to copy file");
    CamelContext ctx = new DefaultCamelContext();
    RouteBuilder route = new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("file://Users/aranja2/Documents/in/?fileName=sample.txt&charset=utf-8")
             .to("file://Users/aranja2/Documents/out/?fileName=sample.txt&charset=utf-8");
        }
    };
    ctx.addRoutes(route);
    ctx.start();
    // Maybe sleep a little here
    // Thread.sleep(4000);
    ctx.stop();
 }
}

我正在使用骆驼来复制文件,但它没有发生 . 我正在使用mac . 抛出的消息是

[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2(CamelContext:camel-1)正在启动[main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX已启用[main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - 已加载183类型转换器[main] INFO org.apache.camel.impl.DefaultRuntimeEndpointRegistry - 运行时 endpoints 注册表处于扩展模式,收集所有传入和传出 endpoints 的使用情况统计信息(缓存限制: 1000)[main] INFO org.apache.camel.impl.DefaultCamelContext - 启用AllowUseOriginalMessage . 如果不需要访问原始邮件,则建议关闭此选项,因为它可能会提高性能 . [main] INFO org.apache.camel.impl.DefaultCamelContext - StreamCaching未使用 . 如果使用流,则建议启用流缓存 . 有关更多详细信息,请访问http://camel.apache.org/stream-caching.html [main] INFO org.apache.camel.component.file.FileEndpoint - endpoints 配置为noop = true,因此强制 endpoints 也是幂等的[main] INFO org.apache.camel.component.file.FileEndpoint - 使用基于默认内存的幂等存储库和缓存最大大小:1000 [main] INFO org.apache.camel.impl.DefaultCamelContext - 路由:route1已启动并消耗来自: endpoints [file:// Users / aranja2 / Documents / in /?noop = true] [main] INFO org.apache.camel.impl.DefaultCamelContext - 总共1条路由,其中1条已启动 . [主要] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2(CamelContext:camel-1)在0.344秒内启动[主要] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2( CamelContext:camel-1)正在关闭[main] INFO org.apache.camel.impl.DefaultShutdownStrategy - 开始正常关闭1个路由(超时300秒)[Camel(camel-1)线程#1 - ShutdownTask] INFO组织 . apache.camel.impl.DefaultShutdownStrategy - 路由:route1 shutdown complete,正在使用:Endpoint [file:// Users / aranja2 / Documents / in /?noop = true] [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - 在0秒内完成1条路线的正常关闭[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2(CamelContext:camel-1)正常运行时间0.359秒[主要] INFO org.apache.camel.impl .DefaultCamelContext - Apache Camel 2.16.2(CamelContext:camel-1)在0.007秒内关闭

1 回答

  • 0

    你确定你到达//Users/aranja2/Documents/in/?fileName=sample.txt上的那个目录吗?你溃败似乎没问题 . 我附加了一个示例项目,其中路径从一个目录复制到另一个目录 . 此诡计使用与您相同的参数 fileName . 你可以运行它 mvn camel:run

    https://drive.google.com/file/d/0B9AooXd3hwFyWjZ4aEFRc0Znam8/view?usp=sharing

    干杯!

相关问题