public interface ApplyMore
The most common application of this mechanism is in the event handler method of an aggregate. Say that an event handler for an event of type A applies another event of type B and then an event of type C. Only after the processing of event A is finished will event B be applied to the aggregate. That means that the effects of event B will not be visible from within the event handler. This is a problem if event C depends on the changes caused by event B. The ApplyMore mechanism solves this problem by allowing clients to apply additional events after previous events have been fully processed.
Be careful not to make any direct changes to the aggregate from the supplier of the subsequent event. If the aggregate is event sourced this will cause the aggregate to be in an inconsistent state after event sourcing.
|Modifier and Type||Method and Description|
Execute the given
Apply a subsequent event to the aggregate after applying another event.
payloadOrMessageSupplieris asked to provide the subsequent event the initial event has been fully processed by the aggregate.
If the given supplier passes an object that is an instance of a
event is applied with the metadata from the message. If the supplied event is not a Message instance it will be
applied as an event without additional metadata.
payloadOrMessageSupplier- The next event message or the payload of the next event
runnableafter applying the previous event. This
runnableis guaranteed to be invoked when the previous event has been fully applied to the aggregate.
runnable must not directly alter any state of the aggregate. Instead, it should only decide
if more events should be applied based on the state of the aggregate after the previous event
runnable- the code to execute when the previous event was applied
Copyright © 2010–2022. All rights reserved.