Interface DeadlineManager

All Known Implementing Classes:
AbstractDeadlineManager, DbSchedulerDeadlineManager, JobRunrDeadlineManager, QuartzDeadlineManager, SimpleDeadlineManager, StubDeadlineManager

public interface DeadlineManager
Contract for deadline managers. Contains methods for scheduling a deadline and for cancelling a deadline.

The overloads that take no ScopeDescriptor use Scope.describeCurrentScope(), as in Axon Framework 4. A Saga is the current Scope while one of its handler methods runs, so calling them from a Saga handler schedules or cancels within that Saga's scope, regardless of how the DeadlineManager was obtained. Calling them while no scope is active throws an IllegalStateException.

This contract exists to keep deadlines that were scheduled with Axon Framework 4 firing while migrating. Scheduling new deadlines is therefore deprecated, while cancelling them stays fully supported.

Since:
3.3
Author:
Milan Savic, Steven van Beelen
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cancelAll(String deadlineName)
    Cancels all the deadlines corresponding to the given deadlineName.
    default void
    Cancels all deadlines corresponding to the given deadlineName that are scheduled within Scope.describeCurrentScope().
    void
    Cancels all deadlines corresponding to the given deadlineName and scope.
    void
    cancelSchedule(String deadlineName, String scheduleId)
    Cancels the deadline corresponding to the given deadlineName / scheduleId combination.
    default String
    schedule(Duration triggerDuration, String deadlineName)
    Deprecated.
    scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating.
    default String
    schedule(Duration triggerDuration, String deadlineName, @Nullable Object messageOrPayload)
    Deprecated.
    scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating.
    default String
    schedule(Duration triggerDuration, String deadlineName, @Nullable Object messageOrPayload, ScopeDescriptor deadlineScope)
    Deprecated.
    scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating.
    default String
    schedule(Instant triggerDateTime, String deadlineName)
    Deprecated.
    scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating.
    default String
    schedule(Instant triggerDateTime, String deadlineName, @Nullable Object messageOrPayload)
    Deprecated.
    scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating.
    schedule(Instant triggerDateTime, String deadlineName, @Nullable Object messageOrPayload, ScopeDescriptor deadlineScope)
    Deprecated.
    scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating.
    default void
    Shuts down this deadline manager.
  • Method Details

    • schedule

      @Deprecated(since="5.4.0") default String schedule(Instant triggerDateTime, String deadlineName)
      Deprecated.
      scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating. Schedule a command with a scheduler of choice that dispatches it through the CommandGateway instead, or replace the Saga with a Workflow
      Schedules a deadline at given triggerDateTime with given deadlineName. The payload of this deadline will be null, as none is provided. The returned scheduleId and provided deadlineName combination can be used to cancel the scheduled deadline. The scope within which this call is made will be retrieved by the DeadlineManager itself.
      Parameters:
      triggerDateTime - a Instant denoting the moment to trigger the deadline handling
      deadlineName - a String representing the name of the deadline to schedule
      Returns:
      the scheduleId as a String to use when cancelling the schedule
    • schedule

      @Deprecated(since="5.4.0") default String schedule(Instant triggerDateTime, String deadlineName, @Nullable Object messageOrPayload)
      Deprecated.
      scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating. Schedule a command with a scheduler of choice that dispatches it through the CommandGateway instead, or replace the Saga with a Workflow
      Schedules a deadline at given triggerDateTime with given deadlineName. The returned scheduleId and provided deadlineName combination can be used to cancel the scheduled deadline. The scope within which this call is made will be retrieved by the DeadlineManager itself.

      The given messageOrPayload may be any object, as well as a DeadlineMessage. In the latter case, the instance provided is the donor for the payload and Metadata of the actual deadline being used. In the former case, the given messageOrPayload will be wrapped as the payload of a DeadlineMessage.

      Parameters:
      triggerDateTime - a Instant denoting the moment to trigger the deadline handling
      deadlineName - a String representing the name of the deadline to schedule
      messageOrPayload - a Message or payload for a message as an Object
      Returns:
      the scheduleId as a String to use when cancelling the schedule
    • schedule

      @Deprecated(since="5.4.0") String schedule(Instant triggerDateTime, String deadlineName, @Nullable Object messageOrPayload, ScopeDescriptor deadlineScope)
      Deprecated.
      scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating. Schedule a command with a scheduler of choice that dispatches it through the CommandGateway instead, or replace the Saga with a Workflow
      Schedules a deadline at given triggerDateTime with provided context. The returned scheduleId and provided deadlineName combination can be used to cancel the scheduled deadline.

      The given messageOrPayload may be any object, as well as a DeadlineMessage. In the latter case, the instance provided is the donor for the payload and Metadata of the actual deadline being used. In the former case, the given messageOrPayload will be wrapped as the payload of a DeadlineMessage.

      Parameters:
      triggerDateTime - a Instant denoting the moment to trigger the deadline handling
      deadlineName - a String representing the name of the deadline to schedule
      messageOrPayload - a Message or payload for a message as an Object
      deadlineScope - a ScopeDescriptor describing the scope within which the deadline was scheduled
      Returns:
      the scheduleId as a String to use when cancelling the schedule
    • schedule

      @Deprecated(since="5.4.0") default String schedule(Duration triggerDuration, String deadlineName)
      Deprecated.
      scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating. Schedule a command with a scheduler of choice that dispatches it through the CommandGateway instead, or replace the Saga with a Workflow
      Schedules a deadline after the given triggerDuration with given deadlineName. The payload of this deadline will be null, as none is provided. The returned scheduleId and provided deadlineName combination can be used to cancel the scheduled deadline. The scope within which this call is made will be retrieved by the DeadlineManager itself.
      Parameters:
      triggerDuration - a Duration describing the waiting period before handling the deadline
      deadlineName - a String representing the name of the deadline to schedule
      Returns:
      the scheduleId as a String to use when cancelling the schedule
    • schedule

      @Deprecated(since="5.4.0") default String schedule(Duration triggerDuration, String deadlineName, @Nullable Object messageOrPayload)
      Deprecated.
      scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating. Schedule a command with a scheduler of choice that dispatches it through the CommandGateway instead, or replace the Saga with a Workflow
      Schedules a deadline after the given triggerDuration. The returned scheduleId and provided deadlineName combination can be used to cancel the scheduled deadline. The scope within which this call is made will be retrieved by the DeadlineManager itself.

      The given messageOrPayload may be any object, as well as a DeadlineMessage. In the latter case, the instance provided is the donor for the payload and Metadata of the actual deadline being used. In the former case, the given messageOrPayload will be wrapped as the payload of a DeadlineMessage.

      Parameters:
      triggerDuration - a Duration describing the waiting period before handling the deadline
      deadlineName - a String representing the name of the deadline to schedule
      messageOrPayload - a Message or payload for a message as an Object
      Returns:
      the scheduleId as a String to use when cancelling the schedule
    • schedule

      @Deprecated(since="5.4.0") default String schedule(Duration triggerDuration, String deadlineName, @Nullable Object messageOrPayload, ScopeDescriptor deadlineScope)
      Deprecated.
      scheduling new deadlines through a DeadlineManager is supported only to keep Axon Framework 4 code running while migrating. Schedule a command with a scheduler of choice that dispatches it through the CommandGateway instead, or replace the Saga with a Workflow
      Schedules a deadline after the given triggerDuration with provided context. The provided deadlineName / scheduleId combination can be used to cancel the scheduled deadline.

      The given messageOrPayload may be any object, as well as a DeadlineMessage. In the latter case, the instance provided is the donor for the payload and Metadata of the actual deadline being used. In the former case, the given messageOrPayload will be wrapped as the payload of a DeadlineMessage.

      Parameters:
      triggerDuration - a Duration describing the waiting period before handling the deadline
      deadlineName - a String representing the name of the deadline to schedule
      messageOrPayload - a Message or payload for a message as an Object
      deadlineScope - a ScopeDescriptor describing the scope within which the deadline was scheduled
      Returns:
      the scheduleId as a String to use when cancelling the schedule
    • cancelSchedule

      void cancelSchedule(String deadlineName, String scheduleId)
      Cancels the deadline corresponding to the given deadlineName / scheduleId combination. This method has no impact on deadlines which have already been triggered.
      Parameters:
      deadlineName - a String representing the name of the deadline to cancel
      scheduleId - the String denoting the scheduled deadline to cancel
    • cancelAll

      void cancelAll(String deadlineName)
      Cancels all the deadlines corresponding to the given deadlineName. This method has no impact on deadlines which have already been triggered.
      Parameters:
      deadlineName - a String representing the name of the deadlines to cancel
    • cancelAllWithinScope

      default void cancelAllWithinScope(String deadlineName)
      Cancels all deadlines corresponding to the given deadlineName that are scheduled within Scope.describeCurrentScope(). This method has no impact on deadlines which have already been triggered.
      Parameters:
      deadlineName - a String representing the name of the deadlines to cancel
    • cancelAllWithinScope

      void cancelAllWithinScope(String deadlineName, ScopeDescriptor scope)
      Cancels all deadlines corresponding to the given deadlineName and scope. This method has no impact on deadlines which have already been triggered.
      Parameters:
      deadlineName - a String representing the name of the deadlines to cancel
      scope - a ScopeDescriptor describing the scope within which the deadline was scheduled
    • shutdown

      default void shutdown()
      Shuts down this deadline manager.

      The configuration calls this method for every DeadlineManager it holds when the application shuts down, through the DeadlineManagerLifecycleConfigurationEnhancer. As the method may be called more than once, for example by Spring as the destroy method it infers for a @Bean, implementations have to allow repeated calls: every call after the first has no effect.