3

here is the scenario in my mission critical application: Actor A does some resource intense work, then sends a message to actor B on another physical unix box. B is accessing external network elements and may take long time to process the message. B then sends back process result back to A.

Q1: A looks up B using B's path. if B's unix box is down or B is not started yet, the lookup will fail. akka doc says a deadletter like actor ref is returned. how do i test it is a normal actor ref or deadletter-like actor ref is returned?

Q2: suppose a normal actor ref of B is return. if A uses B.tell() to send msg to B and the msg fails to reach B's mailbox, which is persistent, how do I know it happened so that A can send the msg to a local actor C with persistent mailbox? C will be trying to deliver the message to B forever until it succeeds.

wang.aurora
  • 255
  • 3
  • 8

1 Answers1

3

Answer 1:

system.actorFor(someRemotePath) always gives you a remote actor ref and there is no way to find out by inspecting this ref whether the actor it points to exists or can be reached. The only way to find out whether there is an actor at that given URI is to send a message: if you get a reply then it is alive, if after some reasonable time there has been no reply you have to assume it is down and/or retry—although it could very well have happened that the reply message was lost because of a firewall reboot or whatever.

Answer 2:

Your actor C is the solution to all your problems: you need to always send to C and have that one make sure that the message is eventually acknowledged by the remote actor. There is no way to find out within Akka whether a given message has been delivered to a mailbox, because that would not mean that the actor can successfully process the message anyway.

In general I recommend reading the documentation on message delivery guarantees, especially before implementing mission critical applications.

Sergey Khudyakov
  • 1,122
  • 1
  • 8
  • 15
Roland Kuhn
  • 15,412
  • 2
  • 36
  • 45
  • Roland many thanks for your quick reply! to solve question 1, i am going to let actor B response a simple ping message. to solve question 2, i am going to try this solution: actor B uses non-persist mailbox. B would persist the message in DB and then send ack back. – wang.aurora Feb 03 '13 at 15:53