Class SimpleEventScheduler
java.lang.Object
org.axonframework.eventhandling.scheduling.java.SimpleEventScheduler
- All Implemented Interfaces:
EventScheduler,Lifecycle
An
EventScheduler implementation that uses Java's ScheduledExecutorService as scheduling and triggering
mechanism.
Note that this mechanism is non-persistent. Scheduled tasks will be lost when the JVM is shut down, unless special
measures have been taken to prevent that. For more flexible and powerful scheduling options, see QuartzEventScheduler.- Since:
- 0.7
- Author:
- Allard Buijze
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aSimpleEventScheduler.Nested classes/interfaces inherited from interface org.axonframework.lifecycle.Lifecycle
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aSimpleEventSchedulerbased on the fields contained in theSimpleEventScheduler.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleEventScheduler.Builderbuilder()Instantiate a Builder to be able to create aSimpleEventScheduler.voidcancelSchedule(ScheduleToken scheduleToken) Cancel the publication of a scheduled event.voidRegisters the activities to be executed in the various phases of an application's lifecycle.Schedule the giveneventfor publication after the giventriggerDuration.Schedule the giveneventfor publication at the giventriggerDateTime.voidshutdown()Shuts down this event scheduler.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.eventhandling.scheduling.EventScheduler
reschedule, reschedule
-
Constructor Details
-
SimpleEventScheduler
Instantiate aSimpleEventSchedulerbased on the fields contained in theSimpleEventScheduler.Builder.Will assert that the
ScheduledExecutorService,EventBusandTransactionManagerare notnull, and will throw anAxonConfigurationExceptionif any of them isnull.- Parameters:
builder- theSimpleEventScheduler.Builderused to instantiate aSimpleEventSchedulerinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aSimpleEventScheduler.The
TransactionManageris defaulted to aNoTransactionManager. TheScheduledExecutorServiceandEventBusare a hard requirements and as such should be provided.- Returns:
- a Builder to be able to create a
SimpleEventScheduler
-
schedule
Description copied from interface:EventSchedulerSchedule 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.- Specified by:
schedulein interfaceEventScheduler- Parameters:
triggerDateTime- The moment to trigger publication of the eventevent- The event to publish- Returns:
- the token to use when cancelling the schedule
-
schedule
Description copied from interface:EventSchedulerSchedule 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.- Specified by:
schedulein interfaceEventScheduler- 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
Description copied from interface:EventSchedulerCancel the publication of a scheduled event. If the events has already been published, this method does nothing.- Specified by:
cancelSchedulein interfaceEventScheduler- Parameters:
scheduleToken- the token returned when the event was scheduled
-
registerLifecycleHandlers
Description copied from interface:LifecycleRegisters the activities to be executed in the various phases of an application's lifecycle. This could either be at startup, shutdown, or both.- Specified by:
registerLifecycleHandlersin interfaceLifecycle- Parameters:
lifecycle- the lifecycle instance to register the handlers with- See Also:
-
shutdown
public void shutdown()Description copied from interface:EventSchedulerShuts down this event scheduler.- Specified by:
shutdownin interfaceEventScheduler
-