开发者

Not able to receive file at Http producer(tomcat server)

  1. I am starting now with Camel. I am trying to create route as to process file from a file component and pass on to a http tomcat server.
  2. I have created the route as follows

from("file:inbox?noop=false").to("http://localhost:8080/myServer/");

I have also tried using my I.P address in place of localhost

  1. I am not getting any compilation error nor at runtime and the file is getting processed from inbox folder, but I am not able to receive the file in myServer directory.
  2. Camel versio开发者_开发百科n I am using is 2.0.0 .


yep, this should work...you should use the latest version of Camel though (2.8.2 currently)...here is a simple unit test to show the FILE->HTTP in action...

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}");
            };
        };
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜