diff --git a/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala b/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala index fe1f73c..48a343a 100644 --- a/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala +++ b/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala @@ -19,7 +19,7 @@ object ImmutableRoundRobin { private def activeRoutingBehavior[T](index: Long, workers: Vector[ActorRef[T]]): Behavior[T] = Actor.immutable[T] { (ctx, msg) => - workers((index % workers.size).toInt) ! msg + workers(abs(index % workers.size).toInt) ! msg activeRoutingBehavior(index + 1, workers) } }