Class ReplicatedEventSourcing
- java.lang.Object
-
- akka.persistence.typed.scaladsl.ReplicatedEventSourcing
-
public class ReplicatedEventSourcing extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ReplicatedEventSourcing()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <Command,Event,State>
EventSourcedBehavior<Command,Event,State>commonJournalConfig(ReplicationId replicationId, scala.collection.immutable.Set<ReplicaId> allReplicaIds, java.lang.String queryPluginId, scala.Function1<ReplicationContext,EventSourcedBehavior<Command,Event,State>> eventSourcedBehaviorFactory)
Initialize a replicated event sourced behavior where all entity replicas are stored in the same journal.static <Command,Event,State>
EventSourcedBehavior<Command,Event,State>perReplicaJournalConfig(ReplicationId replicationId, scala.collection.immutable.Map<ReplicaId,java.lang.String> allReplicasAndQueryPlugins, scala.Function1<ReplicationContext,EventSourcedBehavior<Command,Event,State>> eventSourcedBehaviorFactory)
Initialize a replicated event sourced behavior.
-
-
-
Method Detail
-
commonJournalConfig
public static <Command,Event,State> EventSourcedBehavior<Command,Event,State> commonJournalConfig(ReplicationId replicationId, scala.collection.immutable.Set<ReplicaId> allReplicaIds, java.lang.String queryPluginId, scala.Function1<ReplicationContext,EventSourcedBehavior<Command,Event,State>> eventSourcedBehaviorFactory)
Initialize a replicated event sourced behavior where all entity replicas are stored in the same journal.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:
allReplicaIds
- All replica ids. These need to be known to receive events from all replicas.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 static <Command,Event,State> EventSourcedBehavior<Command,Event,State> perReplicaJournalConfig(ReplicationId replicationId, scala.collection.immutable.Map<ReplicaId,java.lang.String> allReplicasAndQueryPlugins, scala.Function1<ReplicationContext,EventSourcedBehavior<Command,Event,State>> eventSourcedBehaviorFactory)
Initialize a replicated event sourced behavior.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.
-
-