ClusterSingletonProxy

org.apache.pekko.cluster.singleton.ClusterSingletonProxy
See theClusterSingletonProxy companion object
final class ClusterSingletonProxy(singletonManagerPath: String, settings: ClusterSingletonProxySettings) extends Actor, ActorLogging

The ClusterSingletonProxy works together with the pekko.cluster.singleton.ClusterSingletonManager to provide a distributed proxy to the singleton actor.

The proxy can be started on every node where the singleton needs to be reached and used as if it were the singleton itself. It will then act as a router to the currently running singleton instance. If the singleton is not currently available, e.g., during hand off or startup, the proxy will buffer the messages sent to the singleton and then deliver them when the singleton is finally available. 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 proxy.

The proxy works by keeping track of the oldest cluster member. When a new oldest member is identified, e.g. because the older one left the cluster, or at startup, the proxy will try to identify the singleton on the oldest member by periodically sending an pekko.actor.Identify message until the singleton responds with its pekko.actor.ActorIdentity.

Note that this is a best effort implementation: messages can always be lost due to the distributed nature of the actors involved.

Attributes

Companion
object
Source
ClusterSingletonProxy.scala
Graph
Supertypes
trait ActorLogging
trait Actor
class Object
trait Matchable
class Any

Members list

Type members

Inherited types

type Receive = Receive

Attributes

Inherited from:
Actor
Source
Actor.scala

Value members

Concrete methods

def add(m: Member): Unit

Adds new member if it has the right role.

Adds new member if it has the right role.

Value parameters

m

New cluster member.

Attributes

Source
ClusterSingletonProxy.scala
def buffer(msg: Any): Unit

Attributes

Source
ClusterSingletonProxy.scala
def cancelTimer(): Unit

Attributes

Source
ClusterSingletonProxy.scala
def createIdentifyId(i: Int): String

Attributes

Source
ClusterSingletonProxy.scala

Discard old singleton ActorRef and send a periodic message to self to identify the singleton.

Discard old singleton ActorRef and send a periodic message to self to identify the singleton.

Attributes

Source
ClusterSingletonProxy.scala
def matchingRole(member: Member): Boolean

Attributes

Source
ClusterSingletonProxy.scala
override def postStop(): Unit

User overridable callback.

User overridable callback.

Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.

Attributes

Definition Classes
Source
ClusterSingletonProxy.scala
override def preStart(): Unit

User overridable callback.

User overridable callback.

Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation.

Attributes

Definition Classes
Source
ClusterSingletonProxy.scala

Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.

Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.

Attributes

Source
ClusterSingletonProxy.scala
def remove(m: Member): Unit

Removes a member.

Removes a member.

Value parameters

m

Cluster member to remove.

Attributes

Source
ClusterSingletonProxy.scala

Attributes

Source
ClusterSingletonProxy.scala
def trackChange(block: () => Unit): Unit

Attributes

Source
ClusterSingletonProxy.scala

Inherited methods

Attributes

Inherited from:
ActorLogging
Source
Actor.scala

User overridable callback: By default it calls preStart().

User overridable callback: By default it calls preStart().

Value parameters

reason

the Throwable that caused the restart to happen Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.

Attributes

Inherited from:
Actor
Source
Actor.scala

Scala API: User overridable callback: '''By default it disposes of all children and then calls postStop().'''

Scala API: User overridable callback: '''By default it disposes of all children and then calls postStop().'''

Value parameters

message

optionally the current message the actor processed when failing, if applicable Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated.

reason

the Throwable that caused the restart to happen

Attributes

Inherited from:
Actor
Source
Actor.scala
final def sender(): ActorRef

The reference sender Actor of the last received message. Is defined if the message was sent from another Actor, else deadLetters in pekko.actor.ActorSystem.

The reference sender Actor of the last received message. Is defined if the message was sent from another Actor, else deadLetters in pekko.actor.ActorSystem.

WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!

Attributes

Inherited from:
Actor
Source
Actor.scala

User overridable definition the strategy to use for supervising child actors.

User overridable definition the strategy to use for supervising child actors.

Attributes

Inherited from:
Actor
Source
Actor.scala
def unhandled(message: Any): Unit

User overridable callback.

User overridable callback.

Is called when a message isn't handled by the current behavior of the actor by default it fails with either a pekko.actor.DeathPactException (in case of an unhandled pekko.actor.Terminated message) or publishes an pekko.actor.UnhandledMessage to the actor's system's pekko.event.EventStream

Attributes

Inherited from:
Actor
Source
Actor.scala

Implicits

Inherited implicits

implicit val context: ActorContext

Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as forward.

Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as forward.

WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!

pekko.actor.ActorContext is the Scala API. getContext returns a pekko.actor.AbstractActor.ActorContext, which is the Java API of the actor context.

Attributes

Inherited from:
Actor
Source
Actor.scala
final implicit val self: ActorRef

The 'self' field holds the ActorRef for this actor.

The 'self' field holds the ActorRef for this actor.

Can be used to send messages to itself:

self ! message

Attributes

Inherited from:
Actor
Source
Actor.scala