public final class ClusterClient
extends java.lang.Object
implements akka.actor.Actor, akka.actor.ActorLogging
ClusterReceptionist
somewhere in the cluster. It will
monitor the connection to the receptionist and establish a new connection if
the link goes down. When looking for a new receptionist it uses fresh contact
points retrieved from previous establishment, or periodically refreshed
contacts, i.e. not necessarily the initial contact points.
You can send messages via the ClusterClient
to any actor in the cluster
that is registered in the ClusterReceptionist
.
Messages are wrapped in ClusterClient.Send
, ClusterClient.SendToAll
or ClusterClient.Publish
.
1. ClusterClient.Send
-
The message will be delivered to one recipient with a matching path, if any such
exists. If several entries match the path the message will be delivered
to one random destination. The sender of the message can specify that local
affinity is preferred, i.e. the message is sent to an actor in the same local actor
system as the used receptionist actor, if any such exists, otherwise random to any other
matching entry.
2. ClusterClient.SendToAll
-
The message will be delivered to all recipients with a matching path.
3. ClusterClient.Publish
-
The message will be delivered to all recipients Actors that have been registered as subscribers to
to the named topic.
Use the factory method props(akka.cluster.client.ClusterClientSettings)
) to create the
Props
for the actor.
If the receptionist is not currently available, the client will buffer the messages and then deliver them when the connection to the receptionist has been established. The size of the buffer is configurable and it can be disabled by using a buffer size of 0. When the buffer is full old messages will be dropped when new messages are sent via the client.
Note that this is a best effort implementation: messages can always be lost due to the distributed nature of the actors involved.
Modifier and Type | Class and Description |
---|---|
static class |
ClusterClient.Internal$
INTERNAL API
|
static class |
ClusterClient.Publish |
static class |
ClusterClient.Publish$ |
static class |
ClusterClient.Send |
static class |
ClusterClient.Send$ |
static class |
ClusterClient.SendToAll |
static class |
ClusterClient.SendToAll$ |
Constructor and Description |
---|
ClusterClient(ClusterClientSettings settings) |
Modifier and Type | Method and Description |
---|---|
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
active(akka.actor.ActorRef receptionist) |
java.util.LinkedList<scala.Tuple2<java.lang.Object,akka.actor.ActorRef>> |
buffer() |
void |
buffer(java.lang.Object msg) |
scala.collection.immutable.IndexedSeq<akka.actor.ActorSelection> |
contacts() |
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
establishing() |
akka.remote.DeadlineFailureDetector |
failureDetector() |
akka.actor.Cancellable |
heartbeatTask() |
scala.collection.immutable.IndexedSeq<akka.actor.ActorSelection> |
initialContactsSel() |
void |
postStop() |
static akka.actor.Props |
props(ClusterClientSettings settings)
Scala API: Factory method for
ClusterClient Props . |
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receive() |
scala.Option<akka.actor.Cancellable> |
refreshContactsTask() |
void |
scheduleRefreshContactsTick(scala.concurrent.duration.FiniteDuration interval) |
void |
sendBuffered(akka.actor.ActorRef receptionist) |
void |
sendGetContacts() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public ClusterClient(ClusterClientSettings settings)
public static akka.actor.Props props(ClusterClientSettings settings)
ClusterClient
Props
.settings
- (undocumented)public akka.remote.DeadlineFailureDetector failureDetector()
public scala.collection.immutable.IndexedSeq<akka.actor.ActorSelection> initialContactsSel()
public scala.collection.immutable.IndexedSeq<akka.actor.ActorSelection> contacts()
public akka.actor.Cancellable heartbeatTask()
public scala.Option<akka.actor.Cancellable> refreshContactsTask()
public java.util.LinkedList<scala.Tuple2<java.lang.Object,akka.actor.ActorRef>> buffer()
public void scheduleRefreshContactsTick(scala.concurrent.duration.FiniteDuration interval)
public void postStop()
postStop
in interface akka.actor.Actor
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
receive
in interface akka.actor.Actor
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> establishing()
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> active(akka.actor.ActorRef receptionist)
public void sendGetContacts()
public void buffer(java.lang.Object msg)
public void sendBuffered(akka.actor.ActorRef receptionist)