Search code examples
javaerror-handlingakkaactor

Akka message is null


I playing with Akka framework for Java, version 2.3.9 Everything is going fine, but have issue with callback. When I run for callback getSender().tell(null, self());

I get in logs

[akka://system/user/TowerOfDeath:Current:266:ceil:34] Message is null
    akka.actor.InvalidMessageException: Message is null
    at akka.pattern.PromiseActorRef.$bang(AskSupport.scala:266)
    at akka.actor.ActorRef.tell(ActorRef.scala:123)

It's fine, than I can't send null, made small generic message and problem solved. But if that error happens, actor dies. I believe that sometimes possible produce bag, where I will send object, what is now null.

Hot to restore actor in that case?

Thanks for help.


Solution

  • Use Supervision, which allows the parent actor to decide how to deal with failures (bugs) like that:

    Here's an example: http://doc.akka.io/docs/akka/2.3.14/java/fault-tolerance.html#Creating_a_Supervisor_Strategy

    For more information:

    http://doc.akka.io/docs/akka/2.3.14/general/supervision.html http://doc.akka.io/docs/akka/2.3.14/java/fault-tolerance.html