Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/articles/clustering/distributed-publish-subscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ You register actors to the local mediator with `DistributedPubSubMediator.Subscr

You publish messages by sending `DistributedPubSubMediator.Publish` message to the local mediator.

Actors are automatically removed from the registry when they are terminated, or you can explicitly remove entries with `DistributedPubSubMediator.Unsubscribe`.
Topic Actors are automatically removed from the registry when they are terminated - they are terminated if there are zero existing subscribers and no new subscription within a given deadline (the default is 2 minutes). You can change the deadline by setting `removed-time-to-live` to a desired duration. You can `Unsubscribe` from a topic with `DistributedPubSubMediator.Unsubscribe`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aaronontheweb please correct if any error


An example of a subscriber actor:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to turn this into a DocFx ref

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All code samples in this doc need to be updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... they are terminated; they are terminated ...

This would read better if it was two separate sentences. Also, the repeated verbiage looks out of place. It could be changed to something like

... they are terminated. Termination occurs when there are no ....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion cc @eaba

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note taken!

Expand Down Expand Up @@ -205,6 +205,18 @@ It is also possible to broadcast messages to the actors that have been registere

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. You can also optionally specify a property (`AllButSelf`) deciding if the message should be sent to a matching path on the self node or not.


## Deadletter
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aaronontheweb please correct if any!


There are three factors that determine when or if a message is published to Deadletter, namely: `send-to-dead-letters-when-no-subscribers`, zero existing subscribers and terminated topic!

- **`Send-to-dead-letters-when-no-subscribers`**: this is a `DistributedPubSub` setting that, if turned off or set to false (it is on/true by default), causes the sending of messages to the Deadletter to be skipped, when there are zero subscribers or the topic Actor is terminated!

- **Zero Existing Subscribers**: A message is sent to the Deadletter if **`Send-to-dead-letters-when-no-subscribers`** is on/true and there are no existing subscriber(s) to receive it. `Akka.Cluster` distributed pubsub does not support queueing up messages while there are no existing subscribers!

- **Terminated Topic Actor**: When there are no existing subscribers and no new subscription for a duration of, say 2 minutes (the default for `removed-time-to-live`), the Topic Actor is terminated and if **`Send-to-dead-letters-when-no-subscribers`** is on/true, messages are sent to Deadletter.


## DistributedPubSub Extension

In the example above the mediator is started and accessed with the `Akka.Cluster.Tools.PublishSubscribe.DistributedPubSub` extension. That is convenient and perfectly fine in most cases, but it can be good to know that it is possible to start the mediator actor as an ordinary actor and you can have several different mediators at the same time to be able to divide a large number of actors/topics to different mediators. For example you might want to use different cluster roles for different mediators.
Expand Down