0
我們使用Akka框架進行進程間通信。幾天前,QA團隊發現了一些陷入僵局的請求。對於某些請求,不調用onSuccess()和onFailure()回調方法。日誌的最後一行顯示爲akka future onsuccess onfailure都沒有執行
"Charging Customer."
並且該特定事務的流程停在那裏。下一個日誌應該是
"Charging response or Charging Failed"
這種行爲的原因是什麼?這可能是由於調度員被堵塞?我們正在使用默認的調度程序。
代碼
log.debug("Charging Customer");
Future future = Patterns.ask(actorSelection, new Gson().toJson(request), timeout);
future.onSuccess(new onChargingSuccess<>(ccRequest), context().system().dispatcher());
future.onFailure(new onFailureHandler(ccRequest), context().system().dispatcher());
private class onChargingSuccess<T> extends OnSuccess<T> {
@Override
public void onSuccess(T t) throws Throwable {
log.debug("Charging response:" + t.toString());
}
private class onFailureHandler extends OnFailure {
@Override
public void onFailure(Throwable thrwbl) throws Throwable {
log.info("Charging Failed");
}
'timeout'有多長?你有沒有證實日誌輸出是可見的? –
超時時間爲15秒。記錄超時請求。日誌輸出在文件中可見。 –