Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ApacheCamel http到http路由(可能吗?)_Java_Http_Routing_Apache Camel - Fatal编程技术网

Java ApacheCamel http到http路由(可能吗?)

Java ApacheCamel http到http路由(可能吗?),java,http,routing,apache-camel,Java,Http,Routing,Apache Camel,我现在从骆驼开始。我已经看到了http客户端的http4组件和http服务器的jetty组件 我已经看到了几个使用其中一个的例子。 我想知道是否有可能将它们结合在一起 范例 from("jetty:http://0.0.0.0:8080/myapp/myservice") .to("http4://www.google.com"); 这将使camel成为一个简单的基于http的路由器/代理。网络浏览器会点击驼峰URL,取而代之的是谷歌。(谷歌只是一个例子,我有一个真正的基于帖子的服务,我想使用

我现在从骆驼开始。我已经看到了http客户端的http4组件和http服务器的jetty组件

我已经看到了几个使用其中一个的例子。 我想知道是否有可能将它们结合在一起

范例

from("jetty:http://0.0.0.0:8080/myapp/myservice")
.to("http4://www.google.com");
这将使camel成为一个简单的基于http的路由器/代理。网络浏览器会点击驼峰URL,取而代之的是谷歌。(谷歌只是一个例子,我有一个真正的基于帖子的服务,我想使用)

这条路线可行吗?我应该研究骆驼还是需要一个不同的软件框架?将来,我还需要在两者之间添加转换/过滤器

我已经尝试过了,但是得到了一个空指针异常

[qtp757856402-14] SendProcessor       DEBUG >>>> Endpoint[http4://www.google.com] Exchange[Message: [Body is instance of java.io.InputStream]]
[qtp757856402-14] DefaultErrorHandler DEBUG Failed delivery for exchangeId: ID-IT12-53265-1302683969823-0-1. On delivery attempt: 0 caught: java.lang.NullPointerException
[qtp757856402-14] DefaultErrorHandler ERROR Failed delivery for exchangeId: ID-IT12-53265-1302683969823-0-1. Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
java.lang.NullPointerException

您需要桥接端点

from("jetty:http://0.0.0.0:8080/myapp/myservice")
.to("http4://www.google.com?bridgeEndpoint=true&throwExceptionOnFailure=false");

你是否为新的(google.com)地址创建了一个端点?我印象深刻!我从上师那里得到了答案!非常感谢。请继续监视stackoveflow以了解骆驼问题…我只是在护理社区。这也很重要。在了解最终用户如何使用Camel的过程中,我们在以下位置添加了一个关于此解决方案的页面:Just a head up我们在Camel 2.11中添加了url重写支持,它允许您在桥接时更好地控制url映射。这个页面将有更多的细节(在这个时候的写作仍在进行中)-谢谢!这真是太棒了!