Hello there,
Since TypedActors are implemented as plain message sends (the message
representing the proxy method calls is called MethodCall), you can simply
do an untyped router, and then add a typed proxy before it:

"TypedActor Router" must {

  "work" in {
    val t1 = newFooBar
    val t2 = newFooBar
    val t3 = newFooBar
    val t4 = newFooBar
    val routees = List(t1, t2, t3, t4) map { t ⇒
TypedActor(system).getActorRefFor(t).path.toStringWithoutAddress }

    val router = system.actorOf(RoundRobinGroup(routees).props(), "router")

    val typedRouter = TypedActor(system).typedActorOf[Foo,
Foo](TypedProps[Foo](), router)

    info("got = " + typedRouter.optionPigdog())
    info("got = " + typedRouter.optionPigdog())
    info("got = " + typedRouter.optionPigdog())
    info("got = " + typedRouter.optionPigdog())
    info("got = " + typedRouter.optionPigdog())

    mustStop(t1)
    mustStop(t2)
    mustStop(t3)
    mustStop(t4)
  }
}


And with a small modification of the pigdog to include a number (instance
value), we can see that the routing actually works:

[info] TypedActorRouterSpec:
[info] TypedActor Router
[info] - must work (134 milliseconds)
[info]   + got = Some(Pigdog-33)
[info]   + got = Some(Pigdog-46)
[info]   + got = Some(Pigdog-25)
[info]   + got = Some(Pigdog-19)
[info]   + got = Some(Pigdog-33)


// whoa, intellij's new colorized copy paste is a bit weird. Not sure if
awesome or just weird ;-)
-- 
Konrad 'ktoso' Malawski
hAkker @ typesafe
http://akka.io

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to