K
- the aggregate key typeC
- the command typeA
- the aggregate type@FunctionalInterface public interface InvalidSequenceHandler<K,C,A>
readSequence
, which represents the clients view of the aggregate version.
This sequence is checked against the sequence of the internally maintained aggregate version, which is guaranteed to be the latest.
The shouldReject
method will be invoked if and only if these versions do not agree
Normally a client should not have to explicitly implement this interface. There are standard implementations that cover most use cases
These are provided by choosing the appropriate InvalidSequenceStrategy
when using the AggregateBuilder
DSL.Modifier and Type | Method and Description |
---|---|
Optional<CommandError> |
shouldReject(K key,
Sequence expectedSeq,
Sequence currentSeq,
A currentAggregate,
C command)
The sequence handler is responsible for accepting or rejecting commands executed against an out of date view
If expectedSeq == currentSeq this handler will not be invoked
If this handler is invoked, it means the is executing a command against an old version of the aggregate
|
Optional<CommandError> shouldReject(K key, Sequence expectedSeq, Sequence currentSeq, A currentAggregate, C command)
key
- the aggregate keyexpectedSeq
- the current sequence number of the aggregate (i.e. the lastest)currentSeq
- the sequence number passed in the command requestcurrentAggregate
- the current aggregate valuecommand
- the command currently being invokedOptional
with a reason. If the command should still be invoked, return Optional.empty
Copyright © 2019. All rights reserved.