是的,這應該工作...你應該使用最新版本的駱駝雖然目前(2.8.2)...這裏是一個簡單的單元測試,以顯示文件 - > HTTP在行動......
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}");
};
};
}
}
您確定您在端口8080上接受了在'/ myServer' URL處接受輸入的內容嗎? –
是的,我的tomcat服務器運行在同一個端口,我打包在服務器上部署myServer應用程序。 其實我的要求是,我需要創建一個http生產者,它可以使用apache-camel發送文件到http服務器。 –
您是否在訪問日誌中看到/ myServer的任何請求?使用這種類型的路由發送文件的協議是什麼? –