Class ReplicatedEventSourcing$


  • public class ReplicatedEventSourcing$
    extends java.lang.Object
    • Field Detail

      • MODULE$

        public static final ReplicatedEventSourcing$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • ReplicatedEventSourcing$

        public ReplicatedEventSourcing$()
    • Method Detail

      • commonJournalConfig

        public <Command,​Event,​State> EventSourcedBehavior<Command,​Event,​State> commonJournalConfig​(ReplicationId replicationId,
                                                                                                                           java.util.Set<ReplicaId> allReplicaIds,
                                                                                                                           java.lang.String queryPluginId,
                                                                                                                           java.util.function.Function<ReplicationContext,​EventSourcedBehavior<Command,​Event,​State>> behaviorFactory)
        Initialize a replicated event sourced behavior where all entity replicas are share the same journal configuration. This is typical if there is a shared database and no replica specific configuratin is required.

        Events from each replica for the same entityId will be replicated to every copy. Care must be taken to handle events in any order as events can happen concurrently at different replicas.

        Using an replicated event sourced behavior means there is no longer the single writer guarantee.

        A different journal plugin id can be configured using withJournalPluginId after creation. Different databases can be used for each replica. The events from other replicas are read using PersistentQuery.

        Parameters:
        queryPluginId - A single query plugin used to read the events from other replicas. Must be the query side of your configured journal plugin.
      • perReplicaJournalConfig

        public <Command,​Event,​State> EventSourcedBehavior<Command,​Event,​State> perReplicaJournalConfig​(ReplicationId replicationId,
                                                                                                                               java.util.Map<ReplicaId,​java.lang.String> allReplicasAndQueryPlugins,
                                                                                                                               java.util.function.Function<ReplicationContext,​EventSourcedBehavior<Command,​Event,​State>> eventSourcedBehaviorFactory)
        Initialize a replicated event sourced behavior where each journal has different journal configuration e.g. each replica uses a different database or requires different database configuration for a shared database.

        Events from each replica for the same entityId will be replicated to every copy. Care must be taken to handle events in any order as events can happen concurrently at different replicas.

        Using an replicated event sourced behavior means there is no longer the single writer guarantee.

        The journal plugin id for the entity itself can be configured using withJournalPluginId after creation. A query side identifier is passed per replica allowing for separate database/journal configuration per replica. The events from other replicas are read using PersistentQuery.

        Parameters:
        allReplicasAndQueryPlugins - All replica ids and a query plugin per replica id. These need to be known to receive events from all replicas and configured with the query plugin for the journal that each replica uses.