pekko/akka-docs/scala/code/akka/docs/routing/RouterViaConfigExample.scala
2011-12-15 16:36:04 +01:00

22 lines
No EOL
630 B
Scala

package akka.docs.routing
import com.typesafe.config.{ ConfigFactory, Config }
import akka.actor.{ Actor, Props, ActorSystem }
import akka.routing.RoundRobinRouter
case class Message(nbr: Int)
class ExampleActor extends Actor {
def receive = {
case Message(nbr) println("Received %s in router %s".format(nbr, self.path.name))
}
}
object RouterWithConfigExample extends App {
val system = ActorSystem("Example")
//#configurableRouting
val router = system.actorOf(Props[PrintlnActor].withRouter(RoundRobinRouter()),
"exampleActor")
//#configurableRouting
1 to 10 foreach { i router ! Message(i) }
}