Interface EventScheduler
- All Known Implementing Classes:
AxonServerEventScheduler,DbSchedulerEventScheduler,JobRunrEventScheduler,QuartzEventScheduler,SimpleEventScheduler,StubEventScheduler
public interface EventScheduler
Interface towards a mechanism capable of scheduling the publication of events. The accuracy of the publication time
depends on the exact implementation used.
- Since:
- 0.7
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancelSchedule(ScheduleToken scheduleToken) Cancel the publication of a scheduled event.default ScheduleTokenreschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) Cancel a scheduled event and schedule another in its place.default ScheduleTokenreschedule(ScheduleToken scheduleToken, Instant instant, Object event) Cancel a scheduled event and schedule another in its place.Schedule the giveneventfor publication after the giventriggerDuration.Schedule the giveneventfor publication at the giventriggerDateTime.default voidshutdown()Shuts down this event scheduler.
-
Method Details
-
schedule
Schedule the giveneventfor publication at the giventriggerDateTime. The returned ScheduleToken can be used to cancel the planned publication. The giveneventmay be any object, as well as an EventMessage. In the latter case, the instance provided is the donor for the payload and Meta Data of the actual message being dispatched. In the former case, the giveneventwill be wrapped as the payload of an EventMessage.- Parameters:
triggerDateTime- The moment to trigger publication of the eventevent- The event to publish- Returns:
- the token to use when cancelling the schedule
-
schedule
Schedule the giveneventfor publication after the giventriggerDuration. The returned ScheduleToken can be used to cancel the planned publication. The giveneventmay be any object, as well as an EventMessage. In the latter case, the instance provided is the donor for the payload and Meta Data of the actual message being dispatched. In the former case, the giveneventwill be wrapped as the payload of an EventMessage.- Parameters:
triggerDuration- The amount of time to wait before publishing the eventevent- The event to publish- Returns:
- the token to use when cancelling the schedule
-
cancelSchedule
Cancel the publication of a scheduled event. If the events has already been published, this method does nothing.- Parameters:
scheduleToken- the token returned when the event was scheduled- Throws:
IllegalArgumentException- if the token belongs to another scheduler
-
reschedule
default ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) Cancel a scheduled event and schedule another in its place. Convenience method aroundcancelSchedule(ScheduleToken)andschedule(Duration, Object).- Parameters:
scheduleToken- the token returned when the event was scheduled, might be nulltriggerDuration- The amount of time to wait before publishing the eventevent- The event to publish- Returns:
- the token to use when cancelling the schedule
- Throws:
IllegalArgumentException- if the token belongs to another scheduler
-
reschedule
Cancel a scheduled event and schedule another in its place. Convenience method aroundcancelSchedule(ScheduleToken)andschedule(Duration, Object).- Parameters:
scheduleToken- the token returned when the event was scheduled, might be nullinstant- The moment in time to wait before publishing the eventevent- The event to publish- Returns:
- the token to use when cancelling the schedule
- Throws:
IllegalArgumentException- if the token belongs to another scheduler
-
shutdown
default void shutdown()Shuts down this event scheduler.
-