简体   繁体   中英

akka future onsuccess onfailure both didn't execute

We are using Akka framework for inter process communication. Some days back QA team identified some requests which got stuck in limbo. For some requests both onSuccess() and onFailure() callback methods were not called. The last line of log showed

"Charging Customer."

and the flow for that particular transaction stopped there. The next log should be either

"Charging response or Charging Failed"

What could be the reason for such behaviour? Could it be due to the dispatcher getting choked? We are using the default dispatcher.

Code

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");
}

Well its not really a solution but restarting the module fixed the issue. The module was running for an year. I know this makes it a very general question now but i'll keep it here just in case we dig down the actual issue and find the solution. I'll update in that case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM