Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GracefulStop always times out for routers backed by groups of actors #17340

Closed
jschlather opened this issue Apr 29, 2015 · 1 comment
Closed

Comments

@jschlather
Copy link

When initializing a router with a group of actors, I find that gracefulStop always hangs. I can see each individual actor is stopped but the gracefulStop times out. This issue persists regardless of the type of group I'm using. I'm unsure whether this is an issue with my initialization of the router or a bug.

import akka.actor._
import akka.routing._
import akka.pattern._
import java.util.Calendar
import java.util.concurrent.TimeoutException
import scala.concurrent.Await
import scala.concurrent.duration._

object Main {

  class Foo(index: Int) extends Actor {
    def receive = { case _ => println(s"Received by ${index}.") }
    override def postStop() = { println(s"Stopped ${index}.") }
  }

  def main(args: Array[String]): Unit = {
    val system = ActorSystem("test")
    val fooActors = (1 to 10).map(i => system.actorOf(Props(new Foo(i)), s"foo-${i}"))
    val fooRouter = system.actorOf(Props.empty.withRouter(
      RoundRobinGroup(fooActors.map(_.path.toStringWithoutAddress))), "foo-router")
    fooRouter ! Broadcast("bar")
    println("Shutting down Foo router :" + Calendar.getInstance().getTime())
    try {
      Await.result(gracefulStop(fooRouter, 10 seconds, Broadcast(PoisonPill)), 10 seconds)
    } catch {
      case te: TimeoutException => println("Timed out waiting for router to stop.")
    }
    println("Done shutting down Foo router :" + Calendar.getInstance().getTime())
    system.shutdown()
  }
}
@rkuhn
Copy link
Contributor

rkuhn commented Jun 16, 2015

This works as intended: Groups don’t supervise their routees, hence they also don’t monitor them. This is why they are configured with an ActorPath instead of ActorRefs.

@rkuhn rkuhn closed this as completed Jun 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants