public class DefaultConflictResolver extends Object implements ConflictResolver
ConflictResolver
that fetches any unseen changes from the EventStore
.Constructor and Description |
---|
DefaultConflictResolver(EventStore eventStore,
String aggregateIdentifier,
long expectedVersion,
long actualVersion)
Initializes a
DefaultConflictResolver using the given eventStore to load unseen events since
given expectedVersion . |
Modifier and Type | Method and Description |
---|---|
<T extends Exception> |
detectConflicts(Predicate<List<DomainEventMessage<?>>> predicate,
ContextAwareConflictExceptionSupplier<T> exceptionSupplier)
Resolve conflicts between unseen changes made to the aggregate and new changes that are about to be made.
|
void |
ensureConflictsResolved()
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
detectConflicts, detectConflicts
public DefaultConflictResolver(EventStore eventStore, String aggregateIdentifier, long expectedVersion, long actualVersion)
DefaultConflictResolver
using the given eventStore
to load unseen events since
given expectedVersion
.eventStore
- the event store to load unseen eventsaggregateIdentifier
- the identifier of the event sourced aggregate that is being modifiedexpectedVersion
- the last seen version (sequence number) of the aggregateactualVersion
- the actual version (sequence number) of the aggregatepublic <T extends Exception> void detectConflicts(Predicate<List<DomainEventMessage<?>>> predicate, ContextAwareConflictExceptionSupplier<T> exceptionSupplier) throws T extends Exception
ConflictResolver
Conflicts are detected using the given predicate
. If the Predicate.test(Object)
method
returns true
a conflict is registered. If a conflict is registered an instance of ConflictingModificationException
(or subtype) is thrown immediately. The cause of the exception is supplied
by the given causeSupplier
(supplying a null
cause is allowed).
detectConflicts
in interface ConflictResolver
predicate
- test for conflicting unseen changes. Returns true
if there is a conflict.exceptionSupplier
- exception to throw when a conflict is detectedT
- The type of exception to throw when conflicts are detectedT extends Exception
public void ensureConflictsResolved()
detectConflicts(java.util.function.Predicate<java.util.List<org.axonframework.eventhandling.DomainEventMessage<?>>>, org.axonframework.eventsourcing.conflictresolution.ContextAwareConflictExceptionSupplier<T>)
). If not, an instance of ConflictingModificationException
(or subtype) should be thrown if there have been any unseen changes.Copyright © 2010–2024. All rights reserved.