@DeadlineHandlerannotated method) to be executed after a certain amount of time. The context of this execution is an Aggregate or a Saga in which the Deadline was scheduled. If the Deadline becomes obsolete there is the possibility to cancel it as well.
DeadlineManagercomponent is responsible for scheduling deadlines and invoking
@DeadlineHandlers when the deadline is met. The
DeadlineManagercan be injected as a resource. It has two flavors:
QuartzDeadlineManager, just like the Event Scheduling mechanism for Sagas.
Durationafter which it will be triggered (or
Instanceat which it will be triggered) and a name.
Note Unlike Event Scheduling, when a Deadline is triggered there will be no storing of the published Message. Scheduling/Triggering a deadline does not involve an EventBus (or 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 for example 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).
NoteIt is possible to cancel all deadlines of a given name by invoking
DeadlineManagerinstead of letting the
DeadlineManagergenerate an identifier automatically.
@DeadlineHandleris invoked. A
@DeadlineHandleris a Message Handler as any other in Axon - it is possible to inject parameters for which the
NoteWhen scheduling a deadline, the context from where it was scheduled is taken into account. That means a given 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 Scope will allow you to schedule Deadlines in your custom, scoped components.
@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 neither.