Class DbSchedulerEventScheduler
java.lang.Object
org.axonframework.eventhandling.scheduling.dbscheduler.DbSchedulerEventScheduler
- All Implemented Interfaces:
EventScheduler,Lifecycle
EventScheduler implementation that delegates scheduling and triggering to a db-scheduler Scheduler.
- Since:
- 4.8.0
- Author:
- Gerard Klijs
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aDbSchedulerEventScheduler.Nested classes/interfaces inherited from interface org.axonframework.lifecycle.Lifecycle
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aDbSchedulerEventSchedulerbased on the fields contained in theDbSchedulerEventScheduler.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.github.kagkarlsson.scheduler.task.Task<DbSchedulerBinaryEventData> binaryTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier) builder()Instantiate a Builder to be able to create aDbSchedulerEventScheduler.voidcancelSchedule(ScheduleToken scheduleToken) Cancel the publication of a scheduled event.static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerHumanReadableEventData> humanReadableTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier) 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.voidstart()Will start theSchedulerdepending on its current state and the value ofstartScheduler,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
-
DbSchedulerEventScheduler
Instantiate aDbSchedulerEventSchedulerbased on the fields contained in theDbSchedulerEventScheduler.Builder.Will assert that the
Scheduler,SerializerandEventBusare notnull, and will throw anAxonConfigurationExceptionif any of them isnull.- Parameters:
builder- theDbSchedulerEventScheduler.Builderused to instantiate aDbSchedulerEventSchedulerinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aDbSchedulerEventScheduler.The
TransactionManageris defaulted to aNoTransactionManager. TheuseBinaryPojois defaulted totrue.The
Scheduler,SerializerandEventBusare hard requirements and as such should be provided.- Returns:
- a Builder to be able to create a
DbSchedulerEventScheduler
-
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
-
humanReadableTask
public static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerHumanReadableEventData> humanReadableTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier) Gives theTaskusingDbSchedulerBinaryEventDatato publish an event via aScheduler. To be able to execute the task, this should be added to the task list, used to create the scheduler.- Parameters:
eventSchedulerSupplier- aSupplierof aDbSchedulerEventScheduler. Preferably a method involving dependency injection is used. When those are not available theDbSchedulerEventSchedulerSuppliercan be used instead.- Returns:
- a
Taskto publish an event
-
binaryTask
public static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerBinaryEventData> binaryTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier) Gives theTaskusingDbSchedulerHumanReadableEventDatato publish an event via aScheduler. To be able to execute the task, this should be added to the task list, used to create the scheduler.- Parameters:
eventSchedulerSupplier- aSupplierof aDbSchedulerEventScheduler. Preferably a method involving dependency injection is used. When those are not available theDbSchedulerEventSchedulerSuppliercan be used instead.- Returns:
- a
Taskto publish an event
-
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
-
start
public void start()Will start theSchedulerdepending on its current state and the value ofstartScheduler, -
shutdown
public void shutdown()Description copied from interface:EventSchedulerShuts down this event scheduler.- Specified by:
shutdownin interfaceEventScheduler
-
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:
-