Seems odd to me, so this is posted with the caveat that may be a better, more idiomatic way of achieving the same result, but to immediately fail an actor using the ask pattern when there has been some sort of remoting failure:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RemoteErrorActor extends UntypedActor { | |
@SuppressWarnings("rawtypes") | |
@Override | |
public void onReceive(Object o) throws Exception { | |
if (o instanceof RemoteClientWriteFailed) { | |
RemoteClientWriteFailed fail = (RemoteClientWriteFailed) o; | |
if (fail.getRequest() instanceof Tuple3) { | |
Tuple3 t3 = (Tuple3) fail.getRequest(); | |
if (t3._2() instanceof Some) { | |
Some s = (Some) t3._2(); | |
if (s.get() instanceof PromiseActorRef) { | |
PromiseActorRef par = (PromiseActorRef) s.get(); | |
par.tell(/*something useful*/, self()); | |
} | |
} | |
} | |
} | |
} | |
} | |
system.eventStream().subscribe(system.actorOf(new Props(RemoteErrorActor.class)), | |
RemoteClientWriteFailed.class); |