akka.routing
Class Router

java.lang.Object
  extended by akka.routing.Router
All Implemented Interfaces:
java.io.Serializable, scala.Equals, scala.Product

public final class Router
extends java.lang.Object
implements scala.Product, scala.Serializable

For each message that is sent through the router via the route(java.lang.Object, akka.actor.ActorRef) method the RoutingLogic decides to which Routee to send the message. The Routee itself knows how to perform the actual sending. Normally the RoutingLogic picks one of the contained routees, but that is up to the implementation of the RoutingLogic.

A Router is immutable and the RoutingLogic must be thread safe.

See Also:
Serialized Form

Constructor Summary
Router(RoutingLogic logic)
          Java API
Router(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
           
Router(RoutingLogic logic, java.lang.Iterable<Routee> routees)
          Java API
 
Method Summary
 Router addRoutee(ActorRef ref)
          Create a new instance with one more ActorRefRoutee for the specified ActorRef and the same RoutingLogic.
 Router addRoutee(ActorSelection sel)
          Create a new instance with one more ActorSelectionRoutee for the specified ActorSelection and the same RoutingLogic.
 Router addRoutee(Routee routee)
          Create a new instance with one more routee and the same RoutingLogic.
 RoutingLogic logic()
           
 Router removeRoutee(ActorRef ref)
          Create a new instance without the ActorRefRoutee for the specified ActorRef.
 Router removeRoutee(ActorSelection sel)
          Create a new instance without the ActorSelectionRoutee for the specified ActorSelection.
 Router removeRoutee(Routee routee)
          Create a new instance without the specified routee.
 void route(java.lang.Object message, ActorRef sender)
          Send the message to the destination Routee selected by the RoutingLogic.
 scala.collection.immutable.IndexedSeq<Routee> routees()
           
 Router withRoutees(scala.collection.immutable.IndexedSeq<Routee> rs)
          Create a new instance with the specified routees and the same RoutingLogic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface scala.Product
productArity, productElement, productIterator, productPrefix
 
Methods inherited from interface scala.Equals
canEqual, equals
 

Constructor Detail

Router

public Router(RoutingLogic logic,
              scala.collection.immutable.IndexedSeq<Routee> routees)

Router

public Router(RoutingLogic logic)
Java API

Parameters:
logic - (undocumented)

Router

public Router(RoutingLogic logic,
              java.lang.Iterable<Routee> routees)
Java API

Parameters:
logic - (undocumented)
routees - (undocumented)
Method Detail

logic

public RoutingLogic logic()

routees

public scala.collection.immutable.IndexedSeq<Routee> routees()

route

public void route(java.lang.Object message,
                  ActorRef sender)
Send the message to the destination Routee selected by the RoutingLogic. If the message is a RouterEnvelope it will be unwrapped before sent to the destinations. Messages wrapped in a Broadcast envelope are always sent to all routees.

Parameters:
message - (undocumented)
sender - (undocumented)

withRoutees

public Router withRoutees(scala.collection.immutable.IndexedSeq<Routee> rs)
Create a new instance with the specified routees and the same RoutingLogic.

Parameters:
rs - (undocumented)
Returns:
(undocumented)

addRoutee

public Router addRoutee(Routee routee)
Create a new instance with one more routee and the same RoutingLogic.

Parameters:
routee - (undocumented)
Returns:
(undocumented)

addRoutee

public Router addRoutee(ActorRef ref)
Create a new instance with one more ActorRefRoutee for the specified ActorRef and the same RoutingLogic.

Parameters:
ref - (undocumented)
Returns:
(undocumented)

addRoutee

public Router addRoutee(ActorSelection sel)
Create a new instance with one more ActorSelectionRoutee for the specified ActorSelection and the same RoutingLogic.

Parameters:
sel - (undocumented)
Returns:
(undocumented)

removeRoutee

public Router removeRoutee(Routee routee)
Create a new instance without the specified routee.

Parameters:
routee - (undocumented)
Returns:
(undocumented)

removeRoutee

public Router removeRoutee(ActorRef ref)
Create a new instance without the ActorRefRoutee for the specified ActorRef.

Parameters:
ref - (undocumented)
Returns:
(undocumented)

removeRoutee

public Router removeRoutee(ActorSelection sel)
Create a new instance without the ActorSelectionRoutee for the specified ActorSelection.

Parameters:
sel - (undocumented)
Returns:
(undocumented)