Scala system.shutdown not working

563 Views Asked by At

I am sending a message from one actor to kill another actor. The receiver actor executes context.system.shutdown. Although the actor is perfectly receiving the message and executing the code specified in the case statement, it just wont shut down. What is going wrong?

Receive method of the receiver actor.

def receive = {
  ...

  case "KILL" => context.system.shutdown
}
1

There are 1 best solutions below

1
Sascha Kolberg On
case "KILL" => context.system.shutdown()

should shut down the whole actor system. With the code you've given I don't see why it would not. As you have tagged your question with remote-actors, I could imagine that you might have some logic to restart the remote actor system on failure.

However, to just kill one actor you would not shut down the whole system but rather stop the one actor:

case "KILL" => context.stop(self)