DistributedPubSubMediator Class |
This actor manages a registry of actor references and replicates the entries to peer actors among all cluster nodes or a group of nodes tagged with a specific role.
The DistributedPubSubMediator is supposed to be started on all nodes, or all nodes with specified role, in the cluster. The mediator can be started with the DistributedPubSub extension or as an ordinary actor.
Changes are only performed in the own part of the registry and those changes are versioned. Deltas are disseminated in a scalable way to other nodes with a gossip protocol. The registry is eventually consistent, i.e. changes are not immediately visible at other nodes, but typically they will be fully replicated to all other nodes after a few seconds.
You can send messages via the mediator on any node to registered actors on any other node. There is three modes of message delivery.
1. Send - The message will be delivered to one recipient with a matching path, if any such exists in the registry. If several entries match the path the message will be sent via the supplied `routingLogic` (default random) to one 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 mediator actor, if any such exists, otherwise route to any other matching entry. A typical usage of this mode is private chat to one other user in an instant messaging application. It can also be used for distributing tasks to registered workers, like a cluster aware router where the routees dynamically can register themselves.
2. SendToAll - The message will be delivered to all recipients with a matching path. Actors with the same path, without address information, can be registered on different nodes. On each node there can only be one such actor, since the path is unique within one local actor system. Typical usage of this mode is to broadcast messages to all replicas with the same path, e.g. 3 actors on different nodes that all perform the same actions, for redundancy.
3. Publish - Actors may be registered to a named topic instead of path. This enables many subscribers on each node. The message will be delivered to all subscribers of the topic. For efficiency the message is sent over the wire only once per node (that has a matching topic), and then delivered to all subscribers of the local topic representation. This is the true pub/sub mode. A typical usage of this mode is a chat room in an instant messaging application.
4. Publish with sendOneMessageToEachGroup - Actors may be subscribed to a named topic with an optional property `group`. If subscribing with a group name, each message published to a topic with the `sendOneMessageToEachGroup` flag is delivered via the supplied `routingLogic` (default random) to one actor within each subscribing group. If all the subscribed actors have the same group name, then this works just like Send and all messages are delivered to one subscribe. If all the subscribed actors have different group names, then this works like normal Publish and all messages are broadcast to all subscribers.
You register actors to the local mediator with Put or Subscribe. `Put` is used together with `Send` and `SendToAll` message delivery modes. The `ActorRef` in `Put` must belong to the same local actor system as the mediator. `Subscribe` is used together with `Publish`. Actors are automatically removed from the registry when they are terminated, or you can explicitly remove entries with Remove or Unsubscribe.
Successful `Subscribe` and `Unsubscribe` is acknowledged with SubscribeAck and UnsubscribeAck replies.
Namespace: Akka.Cluster.Tools.PublishSubscribe
The DistributedPubSubMediator type exposes the following members.
Name | Description | |
---|---|---|
DistributedPubSubMediator |
TBD
|
Name | Description | |
---|---|---|
Log |
TBD
| |
OwnVersions |
TBD
| |
Self |
Gets the self ActorRef
(Inherited from ActorBase.) | |
Sender |
Gets the sending ActorRef of the current message
(Inherited from ActorBase.) |
Name | Description | |
---|---|---|
AroundPostRestart |
Can be overridden to intercept calls to `PostRestart`. Calls `PostRestart` by default.
(Inherited from ActorBase.) | |
AroundPostStop |
Can be overridden to intercept calls to `PostStop`. Calls `PostStop` by default..
(Inherited from ActorBase.) | |
AroundPreRestart |
Can be overridden to intercept calls to `PreRestart`. Calls `PreRestart` by default.
(Inherited from ActorBase.) | |
AroundPreStart |
Can be overridden to intercept calls to `PreStart`. Calls `PreStart` by default.
(Inherited from ActorBase.) | |
AroundReceive |
TBD
(Inherited from ActorBase.) | |
Become(Action) |
Changes the actor's behavior and replaces the current receive handler with the specified handler.
(Inherited from ReceiveActor.) | |
Become(Receive) |
Changes the actor's command behavior and replaces the current receive handler with the specified handler.
(Inherited from ActorBase.) | |
Become(UntypedReceive) |
Changes the actor's behavior and replaces the current receive handler with the specified handler.
(Inherited from UntypedActor.) | |
BecomeStacked(Action) |
Changes the actor's behavior and replaces the current receive handler with the specified handler.
The current handler is stored on a stack, and you can revert to it by calling UnbecomeStacked (Inherited from ReceiveActor.)Remarks Please note, that in order to not leak memory, make sure every call to BecomeStacked(Action)
is matched with a call to UnbecomeStacked. | |
BecomeStacked(Receive) |
Changes the actor's behavior and replaces the current receive handler with the specified handler.
The current handler is stored on a stack, and you can revert to it by calling UnbecomeStacked (Inherited from ActorBase.)Remarks Please note, that in order to not leak memory, make sure every call to BecomeStacked(Receive)
is matched with a call to UnbecomeStacked. | |
BecomeStacked(UntypedReceive) |
Changes the actor's behavior and replaces the current receive handler with the specified handler.
The current handler is stored on a stack, and you can revert to it by calling UnbecomeStacked (Inherited from UntypedActor.)Remarks Please note, that in order to not leak memory, make sure every call to BecomeStacked(UntypedReceive)
is matched with a call to UnbecomeStacked. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnReceive |
TBD
(Inherited from ReceiveActor.) | |
PostRestart |
User overridable callback: By default it calls `PreStart()`.
Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
(Inherited from ActorBase.) | |
PostStop |
TBD
(Overrides ActorBasePostStop.) | |
PreRestart |
User overridable callback: '''By default it disposes of all children and then calls `postStop()`.'''
Is called on a crashed Actor right BEFORE it is restarted to allow clean
up of resources before Actor is terminated.
(Inherited from ActorBase.) | |
PreStart |
TBD
(Overrides ActorBasePreStart.) | |
Props |
TBD
| |
Receive(Object) |
TBD
(Inherited from UntypedActor.) | |
Receive(Type, FuncObject, Boolean) |
Registers a handler for incoming messages of the specified messageType.
The handler should return true if it has handled the message.
If the handler returns true no more handlers will be tried; otherwise the next registered handler will be tried.
(Inherited from ReceiveActor.)Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
Receive(Type, ActionObject, PredicateObject) |
Registers a handler for incoming messages of the specified messageType.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
Receive(Type, PredicateObject, ActionObject) |
Registers a handler for incoming messages of the specified messageType.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveT(FuncT, Boolean) |
Registers a handler for incoming messages of the specified type T.
The handler should return true if it has handled the message.
If the handler returns true no more handlers will be tried; otherwise the next registered handler will be tried.
(Inherited from ReceiveActor.)Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveT(ActionT, PredicateT) |
Registers a handler for incoming messages of the specified type T.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveT(PredicateT, ActionT) |
Registers a handler for incoming messages of the specified type T.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveAny |
Registers a handler for incoming messages of any type.
(Inherited from ReceiveActor.)Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveAnyAsync |
Registers an asynchronous handler for incoming messages of any type.
(Inherited from ReceiveActor.)Remarks The actor will be suspended until the task returned by handler completes. Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveAsync(Type, FuncObject, Task, PredicateObject) |
Registers an asynchronous handler for incoming messages of the specified messageType.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks The actor will be suspended until the task returned by handler completes. Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveAsync(Type, PredicateObject, FuncObject, Task) |
Registers an asynchronous handler for incoming messages of the specified messageType.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks The actor will be suspended until the task returned by handler completes. Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveAsyncT(FuncT, Task, PredicateT) |
Registers an asynchronous handler for incoming messages of the specified type T.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks The actor will be suspended until the task returned by handler completes. Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
ReceiveAsyncT(PredicateT, FuncT, Task) |
Registers an asynchronous handler for incoming messages of the specified type T.
If shouldHandle!=null then it must return true before a message is passed to handler.
(Inherited from ReceiveActor.)Remarks The actor will be suspended until the task returned by handler completes. Remarks This method may only be called when constructing the actor or from Become(Action) or BecomeStacked(Action). Remarks Note that handlers registered prior to this may have handled the message already.
In that case, this handler will not be invoked. | |
RunTask(Action) |
TBD
(Inherited from UntypedActor.) | |
RunTask(FuncTask) |
TBD
(Inherited from UntypedActor.) | |
SetReceiveTimeout | Defines the inactivity timeout after which the sending of a ReceiveTimeout message is triggered. When specified, the receive function should be able to handle a ReceiveTimeout message. Please note that the receive timeout might fire and enqueue the ReceiveTimeout message right after another message was enqueued; hence it is not guaranteed that upon reception of the receive timeout there must have been an idle period beforehand as configured via this method. Once set, the receive timeout stays in effect (i.e. continues firing repeatedly after inactivity periods). Pass in null to switch off this feature. | |
SupervisorStrategy |
TBD
(Inherited from ActorBase.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
UnbecomeStacked |
Reverts the Actor behavior to the previous one on the behavior stack.
(Inherited from ActorBase.) | |
Unhandled |
Is called when a message isn't handled by the current behavior of the actor
by default it fails with either a DeathPactException (in
case of an unhandled Terminated message) or publishes an UnhandledMessage
to the actor's system's EventStream (Inherited from ActorBase.) |
Name | Description | |
---|---|---|
AsInstanceOfT |
TBD
(Defined by Extensions.) | |
Match | Overloaded.
Matches the specified target.
(Defined by PatternMatch.) | |
MatchT | Overloaded.
Matches the specified target and return a result of target processing.
(Defined by PatternMatch.) |