骆驼初体验 [英] Camel first experience

查看:124
本文介绍了骆驼初体验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新与Apache骆驼。我不能让最简单的例子骆驼工作。这里是code:

I'm very new with Apache Camel. I can't get the simplest Camel example working. Here is the code:

public class CamelFE {
  public static void main(String[] args)  {
    CamelContext cc = new DefaultCamelContext();
    cc.addRoutes(new RouteBuilder() {
      @Override
      public void configure() throws Exception {
        System.out.println("Go!");
        from("file://Users/Foo/Desktop/IN")
        .to("file://Users/Foo/Desktop/OUT");

    });
  }
  cc.start();
  cc.stop();
}

这两个目录中存在,在一个人也没有一个简单的文件, helo.txt 。这条路线开始和去!显示消息,但没有文件被移到了目录。我在想什么?

Both directories exists, in the from one there is one simple file, helo.txt. The route starts and Go! message is displayed but no file was moved to the to directory. What am I missing?

编辑:
这是控制台输出。

SLF4J:无法加载类org.slf4j.impl.StaticLoggerBinder。
SLF4J:默认到无操作(NOP)记录器的实施
SLF4J:见http://www.slf4j.org/$c$cs.html#StaticLoggerBinder进一步的细节
走!

推荐答案

我使用的是Windows,因为你必须 /.../用户桌面引用猜测。如果是这样的话,你的文件的语法是稍微偏离。而不是文件://用户/美孚/桌面,你应该有的file:///用户/美孚/桌面

I'm guessing you're using Windows, since you have references to Users/.../Desktop. If that's the case, your file syntax is slightly off. Rather than file://Users/Foo/Desktop, you should have file:///Users/Foo/Desktop.

您还需要足够的时间让应用程序终止之前发生的处理。你可能会添加一个视频下载。请注意,在Web应用程序中,这不会为应用程序保持运行是一个问题。

You also need to allow enough time for the processing to occur before the application terminates. You might add a Thread.sleep. Note that in a web application, this wouldn't be an issue as the app stays running.

public class CamelFE {
    public static void main(String[] args) throws Exception {
        CamelContext cc = new DefaultCamelContext();
        cc.addRoutes(new RouteBuilder()
        {

            @Override
            public void configure() throws Exception {
                System.out.println("Go!");
                from("file:///Users/Foo/Desktop/IN").to("file:///Users/Foo/Desktop/OUT");
            }
        });

        cc.start();
        Thread.sleep(10000);
        cc.stop();
    }
}

这篇关于骆驼初体验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆