1
在我正在定义路由的Apache Camel中,如何并行发送两个或多个http请求,并等待他们的'期货'以获取进一步处理的响应,如使用AsyncHttpClient进行Java处理?Apache Camel:如何并行发送两个http请求并等待响应?
AsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient();
Future<Response> f = asyncHttpClient.prepareGet("http://www.example.com/").execute();
Response r = f.get();
仅用于上下文,以下路由调用GET联系人http调用并同步返回响应。
from("direct:getContact")
.to("http://host:port/contacts/1453")
我相信你正在寻找的骆驼异步库信息:http://camel.apache.org/async.html –
感谢马修, 我尝试了异步API与ProducerTemplate并面临一些困难。你能否看看我是否做得对吗? http://stackoverflow.com/questions/37409460/apache-camel-producertemplate-not-unmarshalling-the-response – ndsurendra