这是为失败分配回调的方式
future.onFailure(new FailureHandler(), context().system().dispatcher());
在方法FailureHandler()
中public final class FailureHandler extends OnFailure {
public void onFailure(Throwable throwable) throws Throwable {
System.out.println(throwable.toString());
}
}
我无法找到找出哪个请求失败的方法。这是一个常见的要求,我相信我错过了一些微不足道的事情。
答案 0 :(得分:1)
确实很简单,需要声明一个类级变量来保存transactionId onFailure
public final class FailureHandler extends OnFailure {
String transactionId;
public FailureHandler(String transactionId){
this.transactionId = transactionId;
}
@Override
public void onFailure(Throwable throwable) throws Throwable {
logger.error(transactionId + " failed");
}
}