【发布时间】:2016-06-26 21:25:39
【问题描述】:
我有一个螺栓正在为每个元组进行 API 调用 (HTTP Get)。 为了避免需要等待响应,我希望使用 apache HttpAsyncClient。
在bolt的prepare方法中实例化客户端后,execute方法从元组中构造URL并调用sendAsyncGetRequest(url):
private void sendAsyncGetRequest(String url){
httpclient.execute(new HttpGet(url), new FutureCallback<HttpResponse>() {
@Override
public void completed(HttpResponse response) {
LOG.info("Response Code : " + response.getStatusLine());
LOG.debug(response.toString());
}
@Override
public void failed(Exception ex) {
LOG.warn("Async http request failed!", ex);
}
@Override
public void cancelled() {
LOG.warn("Async http request canceled!");
}
});
}
拓扑已部署,但 Storm UI 显示错误:
java.lang.RuntimeException: java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:12
【问题讨论】:
-
我觉得没有足够的数据来检查这个问题。 httpClient 是如何实例化的?你能发布完整的错误堆栈吗?
标签: java apache-storm asynchttpclient