Class DbSchedulerDeadlineManager
- All Implemented Interfaces:
DeadlineManager,Lifecycle,MessageDispatchInterceptorSupport<DeadlineMessage<?>>,MessageHandlerInterceptorSupport<DeadlineMessage<?>>
DeadlineManager 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 aDbSchedulerDeadlineManager.Nested classes/interfaces inherited from interface org.axonframework.lifecycle.Lifecycle
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aDbSchedulerDeadlineManagerbased on the fields contained in theDbSchedulerDeadlineManager.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.github.kagkarlsson.scheduler.task.Task<DbSchedulerBinaryDeadlineDetails> binaryTask(Supplier<DbSchedulerDeadlineManager> deadlineManagerSupplier) builder()Instantiate a Builder to be able to create aDbSchedulerDeadlineManager.voidCancels all the deadlines corresponding to the givendeadlineName.voidcancelAllWithinScope(String deadlineName, ScopeDescriptor scope) Cancels all deadlines corresponding to the givendeadlineNameandscope.voidcancelSchedule(String deadlineName, String scheduleId) Cancels the deadline corresponding to the givendeadlineName/scheduleIdcombination.static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerHumanReadableDeadlineDetails> humanReadableTask(Supplier<DbSchedulerDeadlineManager> deadlineManagerSupplier) voidRegisters the activities to be executed in the various phases of an application's lifecycle.schedule(Instant triggerDateTime, String deadlineName, Object messageOrPayload, ScopeDescriptor deadlineScope) Schedules a deadline at giventriggerDateTimewith provided context.voidshutdown()Shuts down this deadline manager.voidstart()Will start theSchedulerdepending on its current state and the value ofstartScheduler,Methods inherited from class org.axonframework.deadline.AbstractDeadlineManager
dispatchInterceptors, handlerInterceptors, processDispatchInterceptors, registerDispatchInterceptor, registerHandlerInterceptor, runOnPrepareCommitOrNowMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.deadline.DeadlineManager
cancelAllWithinScope, schedule, schedule, schedule, schedule, schedule
-
Constructor Details
-
DbSchedulerDeadlineManager
Instantiate aDbSchedulerDeadlineManagerbased on the fields contained in theDbSchedulerDeadlineManager.Builder.Will assert that the
ScopeAwareProvider,SchedulerandSerializerare notnull, and will throw anAxonConfigurationExceptionif any of them isnull.- Parameters:
builder- theDbSchedulerDeadlineManager.Builderused to instantiate aDbSchedulerDeadlineManagerinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aDbSchedulerDeadlineManager.The
TransactionManageris defaulted to aNoTransactionManager.The
DeadlineManagerSpanFactoryis defaulted to aDefaultDeadlineManagerSpanFactorybacked by aNoOpSpanFactory.The
useBinaryPojoandstartSchedulerare defaulted totrue.The
Scheduler,ScopeAwareProviderandSerializerare hard requirements and as such should be provided.- Returns:
- a Builder to be able to create a
DbSchedulerDeadlineManager
-
schedule
public String schedule(@Nonnull Instant triggerDateTime, @Nonnull String deadlineName, @Nullable Object messageOrPayload, @Nonnull ScopeDescriptor deadlineScope) Description copied from interface:DeadlineManagerSchedules a deadline at giventriggerDateTimewith provided context. The returnedscheduleIdand provideddeadlineNamecombination can be used to cancel the scheduled deadline.The given
messageOrPayloadmay be any object, as well as a DeadlineMessage. In the latter case, the instance provided is the donor for the payload andMetaDataof the actual deadline being used. In the former case, the givenmessageOrPayloadwill be wrapped as the payload of aDeadlineMessage.- Specified by:
schedulein interfaceDeadlineManager- Parameters:
triggerDateTime- AInstantdenoting the moment to trigger the deadline handlingdeadlineName- AStringrepresenting the name of the deadline to schedulemessageOrPayload- AMessageor payload for a message as anObjectdeadlineScope- AScopeDescriptordescribing the scope within which the deadline was scheduled- Returns:
- the
scheduleIdas aStringto use when cancelling the schedule
-
binaryTask
public static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerBinaryDeadlineDetails> binaryTask(Supplier<DbSchedulerDeadlineManager> deadlineManagerSupplier) Gives theTaskusingDbSchedulerBinaryDeadlineDetailsto execute a deadline via aScheduler. To be able to execute the task, this should be added to the task list, used to create the scheduler.- Parameters:
deadlineManagerSupplier- aSupplierof aDbSchedulerDeadlineManager. Preferably a method involving dependency injection is used. When those are not available theDbSchedulerDeadlineManagerSuppliercan be used instead.- Returns:
- a
Taskto execute a deadline
-
humanReadableTask
public static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerHumanReadableDeadlineDetails> humanReadableTask(Supplier<DbSchedulerDeadlineManager> deadlineManagerSupplier) Gives theTaskusingDbSchedulerHumanReadableDeadlineDetailsto execute a deadline via aScheduler. To be able to execute the task, this should be added to the task list, used to create the scheduler.- Parameters:
deadlineManagerSupplier- aSupplierof aDbSchedulerDeadlineManager. Preferably a method involving dependency injection is used. When those are not available theDbSchedulerDeadlineManagerSuppliercan be used instead.- Returns:
- a
Taskto execute a deadline
-
cancelSchedule
Description copied from interface:DeadlineManagerCancels the deadline corresponding to the givendeadlineName/scheduleIdcombination. This method has no impact on deadlines which have already been triggered.- Specified by:
cancelSchedulein interfaceDeadlineManager- Parameters:
deadlineName- aStringrepresenting the name of the deadline to cancelscheduleId- theStringdenoting the scheduled deadline to cancel
-
cancelAll
Description copied from interface:DeadlineManagerCancels all the deadlines corresponding to the givendeadlineName. This method has no impact on deadlines which have already been triggered.- Specified by:
cancelAllin interfaceDeadlineManager- Parameters:
deadlineName- aStringrepresenting the name of the deadlines to cancel
-
cancelAllWithinScope
Description copied from interface:DeadlineManagerCancels all deadlines corresponding to the givendeadlineNameandscope. This method has no impact on deadlines which have already been triggered.- Specified by:
cancelAllWithinScopein interfaceDeadlineManager- Parameters:
deadlineName- aStringrepresenting the name of the deadlines to cancelscope- aScopeDescriptordescribing the scope within which the deadline 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:DeadlineManagerShuts down this deadline manager.- Specified by:
shutdownin interfaceDeadlineManager
-
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:
-