Use RoutedProps to configure Routing (local and remote). Ticket #1060
This commit is contained in:
parent
b121da7d2b
commit
ee4d241ceb
12 changed files with 345 additions and 139 deletions
|
|
@ -9,6 +9,7 @@ import static akka.actor.Actors.poisonPill;
|
|||
import static java.lang.System.currentTimeMillis;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import akka.routing.RoutedProps;
|
||||
import akka.routing.Routing;
|
||||
import scala.Option;
|
||||
import akka.actor.ActorRef;
|
||||
|
|
@ -102,7 +103,12 @@ public class Pi {
|
|||
workers.add(worker);
|
||||
}
|
||||
|
||||
router = Routing.actorOfWithRoundRobin("pi", JavaConversions.asIterable(workers));
|
||||
router = Routing.actorOf(
|
||||
RoutedProps.apply()
|
||||
.withConnections(workers)
|
||||
.withRoundRobinRouter()
|
||||
.withDeployId("pi")
|
||||
)
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
package akka.tutorial.second
|
||||
|
||||
import akka.actor.Actor._
|
||||
import akka.routing.Routing
|
||||
import akka.event.EventHandler
|
||||
import System.{ currentTimeMillis ⇒ now }
|
||||
import akka.routing.Routing.Broadcast
|
||||
import akka.actor.{ Timeout, Channel, Actor, PoisonPill }
|
||||
import akka.routing.{RoutedProps, Routing}
|
||||
|
||||
object Pi extends App {
|
||||
|
||||
|
|
@ -53,7 +53,13 @@ object Pi extends App {
|
|||
val workers = Vector.fill(nrOfWorkers)(actorOf[Worker].start())
|
||||
|
||||
// wrap them with a load-balancing router
|
||||
val router = Routing.actorOfWithRoundRobin("pi", workers)
|
||||
val router = Routing.actorOf(
|
||||
RoutedProps.apply()
|
||||
.withConnections(workers)
|
||||
.withRoundRobinRouter()
|
||||
.withDeployId("pi")
|
||||
|
||||
)
|
||||
|
||||
// phase 1, can accept a Calculate message
|
||||
def scatter: Receive = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue