Class ShardingDirectReplication

  • public class ShardingDirectReplication
    extends java.lang.Object

    Used when sharding Replicated Event Sourced entities in multiple instances of sharding, for example one per DC in a Multi DC Akka Cluster.

    This actor should be started once on each node where Replicated Event Sourced entities will run (the same nodes that you start sharding on). The entities should be set up with akka.persistence.typed.scaladsl.EventSourcedBehavior.withEventPublishing or ReplicatedEventSourcedBehavior.withEventPublishing() If using ReplicatedSharding the replication can be enabled through ReplicatedEntityProvider.withDirectReplication instead of starting this actor manually.

    Subscribes to locally written events through the event stream and sends the seen events to all the sharded replicas which can then fast forward their cross-replica event streams to improve latency while allowing less frequent poll for the cross replica queries. Note that since message delivery is at-most-once this can not be the only channel for replica events - the entities must still tail events from the journals of other replicas.

    The events are forwarded as ShardingEnvelope this will work out of the box both by default and with a custom extractor since the envelopes are handled internally.