DOC: Routing (Java). See #1600
This commit is contained in:
parent
a8c6a0d891
commit
ed2b65c402
13 changed files with 670 additions and 76 deletions
|
|
@ -4,7 +4,8 @@
|
|||
package akka.docs.routing
|
||||
|
||||
import akka.actor.{ Actor, Props, ActorSystem }
|
||||
import akka.routing.RoundRobinRouter
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import akka.routing.FromConfig
|
||||
|
||||
case class Message(nbr: Int)
|
||||
|
||||
|
|
@ -15,10 +16,20 @@ class ExampleActor extends Actor {
|
|||
}
|
||||
|
||||
object RouterWithConfigExample extends App {
|
||||
val system = ActorSystem("Example")
|
||||
val config = ConfigFactory.parseString("""
|
||||
//#config
|
||||
akka.actor.deployment {
|
||||
/router {
|
||||
router = round-robin
|
||||
nr-of-instances = 5
|
||||
}
|
||||
}
|
||||
//#config
|
||||
""")
|
||||
val system = ActorSystem("Example", config)
|
||||
//#configurableRouting
|
||||
val router = system.actorOf(Props[PrintlnActor].withRouter(RoundRobinRouter()),
|
||||
"exampleActor")
|
||||
val router = system.actorOf(Props[ExampleActor].withRouter(FromConfig()),
|
||||
"router")
|
||||
//#configurableRouting
|
||||
1 to 10 foreach { i ⇒ router ! Message(i) }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue