1
votes

I have written a test that send several messages to actor in akka system. When test is finished akka system is shutdowned. The problem is that messages are processed anisochronous and system shutdown before they are processed.

Is there a way to tell akka system to wait untill all messages in mailbox will be processed by actors and then shutdown?

2

2 Answers

3
votes

There is no direct mechanism in Akka to do this (i.e. there are no APIs for this). But a way to implement this is documented in http://letitcrash.com/post/30165507578/shutdown-patterns-in-akka-2. Check for "The Reaper" description in this article. This article also documents why such a mechanism is not available in Akka directly.

0
votes

You should be using Akka TestKit with something like:

override def afterAll {
  TestKit.shutdownActorSystem(system)
}

See the doc for more details.