无法在Http生产者(tomcat服务器)上接收文件

时间:2011-10-10 14:17:26

标签: java apache-camel

  1. 我现在开始与Camel合作。我正在尝试创建路由来处理文件组件中的文件并传递给http tomcat服务器。
  2. 我创建了以下路线
  3. from(“file:inbox?noop = false”).to(“http:// localhost:8080 / myServer /”);

    我也尝试使用我的I.P地址代替localhost

    1. 我没有收到任何编译错误,也没有在运行时,文件正在从收件箱文件夹中处理,但是我无法在myServer目录中收到该文件。
    2. 我使用的Camel版本是2.0.0。

1 个答案:

答案 0 :(得分:0)

是的,这应该有用......你应该使用最新版本的Camel,虽然目前是(2.8.2 ...这里有一个简单的单元测试来显示FILE-&gt; HTTP在行动... < / p>

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

public class FileToHttpRouterTest extends CamelTestSupport {

    @Test
    public void test() throws Exception {
        Thread.sleep(1000);
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("timer://foo?fixedRate=true&period=200")
                    .setBody(simple("${exchangeId}"))
                    .to("file://tmp/inbox");

                from("file://tmp/inbox")
                    .to("http://localhost:9000/myTest");

                from("jetty:http://localhost:9000/myTest")
                    .log("received: ${body}");
            };
        };
    }
}