Package akka.routing
Class Router
- java.lang.Object
-
- akka.routing.Router
-
- All Implemented Interfaces:
java.io.Serializable
,scala.Equals
,scala.Product
public final class Router extends java.lang.Object implements scala.Product, java.io.Serializable
For each message that is sent through the router via theroute(java.lang.Object, akka.actor.ActorRef)
method theRoutingLogic
decides to whichRoutee
to send the message. TheRoutee
itself knows how to perform the actual sending. Normally theRoutingLogic
picks one of the containedroutees
, but that is up to the implementation of theRoutingLogic
.A
Router
is immutable and theRoutingLogic
must be thread safe.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Router(RoutingLogic logic)
Java APIRouter(RoutingLogic logic, java.lang.Iterable<Routee> routees)
Java APIRouter(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static scala.collection.immutable.IndexedSeq<Routee>
$lessinit$greater$default$2()
Router
addRoutee(ActorRef ref)
Create a new instance with one moreActorRefRoutee
for the specifiedActorRef
and the sameRoutingLogic
.Router
addRoutee(ActorSelection sel)
Create a new instance with one moreActorSelectionRoutee
for the specifiedActorSelection
and the sameRoutingLogic
.Router
addRoutee(Routee routee)
Create a new instance with one more routee and the sameRoutingLogic
.static Router
apply(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
static scala.collection.immutable.IndexedSeq<Routee>
apply$default$2()
boolean
canEqual(java.lang.Object x$1)
Router
copy(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
RoutingLogic
copy$default$1()
scala.collection.immutable.IndexedSeq<Routee>
copy$default$2()
boolean
equals(java.lang.Object x$1)
int
hashCode()
RoutingLogic
logic()
int
productArity()
java.lang.Object
productElement(int x$1)
java.lang.String
productElementName(int x$1)
scala.collection.Iterator<java.lang.Object>
productIterator()
java.lang.String
productPrefix()
Router
removeRoutee(ActorRef ref)
Create a new instance without theActorRefRoutee
for the specifiedActorRef
.Router
removeRoutee(ActorSelection sel)
Create a new instance without theActorSelectionRoutee
for the specifiedActorSelection
.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 destinationRoutee
selected by theRoutingLogic
.scala.collection.immutable.IndexedSeq<Routee>
routees()
java.lang.String
toString()
static scala.Option<scala.Tuple2<RoutingLogic,scala.collection.immutable.IndexedSeq<Routee>>>
unapply(Router x$0)
Router
withRoutees(scala.collection.immutable.IndexedSeq<Routee> rs)
Create a new instance with the specified routees and the sameRoutingLogic
.
-
-
-
Constructor Detail
-
Router
public Router(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
-
Router
public Router(RoutingLogic logic)
Java API
-
Router
public Router(RoutingLogic logic, java.lang.Iterable<Routee> routees)
Java API
-
-
Method Detail
-
$lessinit$greater$default$2
public static scala.collection.immutable.IndexedSeq<Routee> $lessinit$greater$default$2()
-
apply
public static Router apply(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
-
apply$default$2
public static scala.collection.immutable.IndexedSeq<Routee> apply$default$2()
-
unapply
public static scala.Option<scala.Tuple2<RoutingLogic,scala.collection.immutable.IndexedSeq<Routee>>> unapply(Router x$0)
-
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 destinationRoutee
selected by theRoutingLogic
. If the message is aRouterEnvelope
it will be unwrapped before sent to the destinations. Messages wrapped in aBroadcast
envelope are always sent to allroutees
.
-
withRoutees
public Router withRoutees(scala.collection.immutable.IndexedSeq<Routee> rs)
Create a new instance with the specified routees and the sameRoutingLogic
.
-
addRoutee
public Router addRoutee(Routee routee)
Create a new instance with one more routee and the sameRoutingLogic
.
-
addRoutee
public Router addRoutee(ActorRef ref)
Create a new instance with one moreActorRefRoutee
for the specifiedActorRef
and the sameRoutingLogic
.
-
addRoutee
public Router addRoutee(ActorSelection sel)
Create a new instance with one moreActorSelectionRoutee
for the specifiedActorSelection
and the sameRoutingLogic
.
-
removeRoutee
public Router removeRoutee(Routee routee)
Create a new instance without the specified routee.
-
removeRoutee
public Router removeRoutee(ActorRef ref)
Create a new instance without theActorRefRoutee
for the specifiedActorRef
.
-
removeRoutee
public Router removeRoutee(ActorSelection sel)
Create a new instance without theActorSelectionRoutee
for the specifiedActorSelection
.
-
copy
public Router copy(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
-
copy$default$1
public RoutingLogic copy$default$1()
-
copy$default$2
public scala.collection.immutable.IndexedSeq<Routee> copy$default$2()
-
productPrefix
public java.lang.String productPrefix()
- Specified by:
productPrefix
in interfacescala.Product
-
productArity
public int productArity()
- Specified by:
productArity
in interfacescala.Product
-
productElement
public java.lang.Object productElement(int x$1)
- Specified by:
productElement
in interfacescala.Product
-
productIterator
public scala.collection.Iterator<java.lang.Object> productIterator()
- Specified by:
productIterator
in interfacescala.Product
-
canEqual
public boolean canEqual(java.lang.Object x$1)
- Specified by:
canEqual
in interfacescala.Equals
-
productElementName
public java.lang.String productElementName(int x$1)
- Specified by:
productElementName
in interfacescala.Product
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object x$1)
- Specified by:
equals
in interfacescala.Equals
- Overrides:
equals
in classjava.lang.Object
-
-