DeadlineManagercomponent is responsible for scheduling deadlines and invoking
@DeadlineHandlerwhen the deadline is met. The
DeadlineManagercan be injected as a resource. It has two flavors:
Durationafter which it will be triggered (or an
Instantat which it will be triggered) and a deadline name.
Scheduled Events or Scheduled DeadlinesUnlike Event Scheduling, when a deadline is triggered there will be no storing of the published message. Scheduling/Triggering a deadline does not involve an
EventStore), hence the message is not stored.
deadlineIdwhich can be used to cancel the deadline. In most cases, storing this
deadlineIdas a field within your Aggregate/Saga is the most convenient. Cancelling a deadline could come in handy when a certain event means that the previously scheduled deadline has become obsolete (e.g. there is a deadline for paying the invoice, but the client payed the amount which means that the deadline is obsolete and can be canceled).
deadlineName, within the
Scopethe method is invoked in.
ScopeDescriptorfrom "aggregate instance X" will be used to cancel.
cancelAllWithinScope(String deadlineName, ScopeDescriptor scope)
@DeadlineHandleris invoked. A
@DeadlineHandleris a message handler like any other in Axon - it is possible to inject parameters for which
The Scope of a DeadlineWhen scheduling a deadline, the context from where it was scheduled is taken into account. This means a scheduled deadline will only be triggered in its originating context. Thus any
@DeadlineHandlerannotated function you wish to be called on a met deadline, must be in the same Aggregate/Saga from which is was scheduled.Axon calls this context a
Scope. If necessary, implementing and providing your own
Scopewill allow you to schedule deadlines in your custom, 'scoped' components.A Saga can end its lifecycle when
@EndSagais added on a deadline handler.
@DeadlineHandleris matched based on the deadline name and the deadline payload.
@DeadlineHandler, matching will proceed based on the deadline payload alone.
@DeadlineHandlerdoes not have to specify the payload.
GenericEventMessage.clock. This clock is set to Clock.systemUTC at runtime, and manipulated to simulate time during testing.