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