public final class ClusterClient extends java.lang.Object implements 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$ |
Actor.emptyBehavior$, Actor.ignoringBehavior$
Constructor and Description |
---|
ClusterClient(ClusterClientSettings settings) |
Modifier and Type | Method and Description |
---|---|
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
active(ActorRef receptionist) |
protected abstract static void |
akka$actor$Actor$_setter_$context_$eq(ActorContext x$1) |
protected abstract static void |
akka$actor$Actor$_setter_$self_$eq(ActorRef x$1) |
static void |
akka$actor$ActorLogging$$_log_$eq(LoggingAdapter x$1) |
static LoggingAdapter |
akka$actor$ActorLogging$$_log() |
protected static void |
aroundPostRestart(java.lang.Throwable reason) |
protected static void |
aroundPostStop() |
protected static void |
aroundPreRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message) |
protected static void |
aroundPreStart() |
protected static void |
aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive,
java.lang.Object msg) |
MessageBuffer |
buffer() |
void |
buffer(java.lang.Object msg) |
scala.collection.immutable.HashSet<ActorPath> |
contactPaths() |
scala.collection.immutable.HashSet<ActorPath> |
contactPathsPublished() |
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
contactPointMessages() |
scala.collection.immutable.HashSet<ActorSelection> |
contacts() |
ActorContext |
context()
Stores the context for this actor, including self, and sender.
|
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
establishing() |
DeadlineFailureDetector |
failureDetector() |
Cancellable |
heartbeatTask() |
scala.collection.immutable.HashSet<ActorSelection> |
initialContactsSel() |
static LoggingAdapter |
log() |
static void |
postRestart(java.lang.Throwable reason) |
void |
postStop()
User overridable callback.
|
static void |
preRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message) |
static void |
preStart() |
static Props |
props(ClusterClientSettings settings)
Scala API: Factory method for
ClusterClient Props . |
void |
publishContactPoints() |
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receive()
This defines the initial actor behavior, it must return a partial function
with the actor logic.
|
scala.Option<Cancellable> |
refreshContactsTask() |
void |
scheduleRefreshContactsTick(scala.concurrent.duration.FiniteDuration interval) |
ActorRef |
self()
The 'self' field holds the ActorRef for this actor.
|
void |
sendBuffered(ActorRef receptionist) |
static ActorRef |
sender() |
void |
sendGetContacts() |
scala.collection.immutable.Vector<ActorRef> |
subscribers() |
static SupervisorStrategy |
supervisorStrategy() |
static void |
unhandled(java.lang.Object message) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, postRestart, preRestart, preStart, sender, supervisorStrategy, unhandled
log
public ClusterClient(ClusterClientSettings settings)
public static Props props(ClusterClientSettings settings)
ClusterClient
Props
.settings
- (undocumented)public static final ActorRef sender()
protected static void aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object msg)
protected static void aroundPreStart()
protected static void aroundPostStop()
protected static void aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)
protected static void aroundPostRestart(java.lang.Throwable reason)
public static SupervisorStrategy supervisorStrategy()
public static void preStart() throws java.lang.Exception
java.lang.Exception
public static void preRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message) throws java.lang.Exception
java.lang.Exception
public static void postRestart(java.lang.Throwable reason) throws java.lang.Exception
java.lang.Exception
public static void unhandled(java.lang.Object message)
protected abstract static void akka$actor$Actor$_setter_$context_$eq(ActorContext x$1)
protected abstract static void akka$actor$Actor$_setter_$self_$eq(ActorRef x$1)
public static LoggingAdapter akka$actor$ActorLogging$$_log()
public static void akka$actor$ActorLogging$$_log_$eq(LoggingAdapter x$1)
public static LoggingAdapter log()
public ActorContext context()
Actor
forward
.
WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
ActorContext
is the Scala API. getContext
returns a
UntypedActorContext
, which is the Java API of the actor
context.
public final ActorRef self()
Actor
self ! message
public DeadlineFailureDetector failureDetector()
public scala.collection.immutable.HashSet<ActorPath> contactPaths()
public scala.collection.immutable.HashSet<ActorSelection> initialContactsSel()
public scala.collection.immutable.HashSet<ActorSelection> contacts()
public scala.collection.immutable.HashSet<ActorPath> contactPathsPublished()
public scala.collection.immutable.Vector<ActorRef> subscribers()
public Cancellable heartbeatTask()
public scala.Option<Cancellable> refreshContactsTask()
public MessageBuffer buffer()
public void scheduleRefreshContactsTick(scala.concurrent.duration.FiniteDuration interval)
public void postStop()
Actor
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Actor
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> establishing()
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> active(ActorRef receptionist)
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> contactPointMessages()
public void sendGetContacts()
public void buffer(java.lang.Object msg)
public void sendBuffered(ActorRef receptionist)
public void publishContactPoints()