public class JobRunrDeadlineManager extends AbstractDeadlineManager implements Lifecycle
DeadlineManager
that delegates scheduling and triggering to a Jobrunr
JobScheduler
.Modifier and Type | Class and Description |
---|---|
static class |
JobRunrDeadlineManager.Builder
Builder class to instantiate a
JobRunrDeadlineManager . |
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry
Modifier and Type | Field and Description |
---|---|
protected static String |
DELETE_REASON |
Modifier | Constructor and Description |
---|---|
protected |
JobRunrDeadlineManager(JobRunrDeadlineManager.Builder builder)
Instantiate a
JobRunrDeadlineManager based on the fields contained in the
JobRunrDeadlineManager.Builder . |
Modifier and Type | Method and Description |
---|---|
static JobRunrDeadlineManager.Builder |
builder()
Instantiate a Builder to be able to create a
JobRunrDeadlineManager . |
void |
cancelAll(String deadlineName)
Cancels all the deadlines corresponding to the given
deadlineName . |
void |
cancelAllWithinScope(String deadlineName,
ScopeDescriptor scope)
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. |
void |
execute(String serializedDeadlineDetails)
Deprecated.
Kept for backwards compatibility, use
execute(String, String) instead. |
void |
execute(String serializedDeadlineDetails,
String deadlineId)
This function should only be called via JobRunr when a deadline was triggered.
|
protected String |
getSpanClassName()
Provides the class to use in spans,
|
void |
registerLifecycleHandlers(Lifecycle.LifecycleRegistry lifecycle)
Registers the activities to be executed in the various phases of an application's lifecycle.
|
String |
schedule(Instant triggerDateTime,
String deadlineName,
Object messageOrPayload,
ScopeDescriptor deadlineScope)
Schedules a deadline at given
triggerDateTime with provided context. |
void |
shutdown()
Shuts down this deadline manager.
|
dispatchInterceptors, handlerInterceptors, processDispatchInterceptors, registerDispatchInterceptor, registerHandlerInterceptor, runOnPrepareCommitOrNow
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cancelAllWithinScope, schedule, schedule, schedule, schedule, schedule
protected static final String DELETE_REASON
protected JobRunrDeadlineManager(JobRunrDeadlineManager.Builder builder)
JobRunrDeadlineManager
based on the fields contained in the
JobRunrDeadlineManager.Builder
.
Will assert that the ScopeAwareProvider
, JobScheduler
and Serializer
are not
null
, and will throw an AxonConfigurationException
if any of them is null
.
builder
- the QuartzDeadlineManager.Builder
used to instantiate a QuartzDeadlineManager
instancepublic static JobRunrDeadlineManager.Builder builder()
JobRunrDeadlineManager
.
The TransactionManager
is defaulted to a NoTransactionManager
.
The SpanFactory
is defaulted to a NoOpSpanFactory
.
The JobScheduler
, ScopeAwareProvider
and Serializer
are hard requirements and as
such should be provided.
JobRunrDeadlineManager
protected String getSpanClassName()
public String schedule(@Nonnull Instant triggerDateTime, @Nonnull String deadlineName, @Nullable Object messageOrPayload, @Nonnull ScopeDescriptor deadlineScope)
DeadlineManager
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
.
schedule
in interface DeadlineManager
triggerDateTime
- A Instant
denoting the moment to trigger the deadline handlingdeadlineName
- A String
representing the name of the deadline to schedulemessageOrPayload
- A Message
or payload for a message as an
Object
deadlineScope
- A ScopeDescriptor
describing the scope within which the deadline was scheduledscheduleId
as a String
to use when cancelling the schedulepublic void cancelSchedule(@Nonnull String deadlineName, @Nonnull String scheduleId)
DeadlineManager
deadlineName
/ scheduleId
combination. This
method has no impact on deadlines which have already been triggered.cancelSchedule
in interface DeadlineManager
deadlineName
- a String
representing the name of the deadline to cancelscheduleId
- the String
denoting the scheduled deadline to cancelpublic void cancelAll(@Nonnull String deadlineName)
DeadlineManager
deadlineName
. This method has no impact on deadlines
which have already been triggered.cancelAll
in interface DeadlineManager
deadlineName
- a String
representing the name of the deadlines to cancelpublic void cancelAllWithinScope(@Nonnull String deadlineName, @Nonnull ScopeDescriptor scope)
DeadlineManager
deadlineName
and scope
.
This method has no impact on deadlines which have already been triggered.cancelAllWithinScope
in interface DeadlineManager
deadlineName
- a String
representing the name of the deadlines to cancelscope
- a ScopeDescriptor
describing the scope within which the deadline was scheduled@Deprecated public void execute(@Nonnull String serializedDeadlineDetails)
execute(String, String)
instead.DeadlineException
in case of errors such that they
will be optionally retried by JobRunr.serializedDeadlineDetails
- byte[]
containing the serialized DeadlineDetails
object with all
the needed details to execute.public void execute(@Nonnull String serializedDeadlineDetails, String deadlineId)
DeadlineException
in case of errors such that they
will be optionally retried by JobRunr.serializedDeadlineDetails
- byte[]
containing the serialized DeadlineDetails
object with all
the needed details to execute.deadlineId
- The UUID
of the deadline.public void shutdown()
DeadlineManager
shutdown
in interface DeadlineManager
public void registerLifecycleHandlers(@Nonnull Lifecycle.LifecycleRegistry lifecycle)
Lifecycle
registerLifecycleHandlers
in interface Lifecycle
lifecycle
- the lifecycle instance to register the handlers withLifecycle.LifecycleRegistry.onShutdown(int, Runnable)
,
LifecycleRegistry#onShutdown(int, LifecycleHandler)
,
Lifecycle.LifecycleRegistry.onStart(int, Runnable)
,
LifecycleRegistry#onStart(int, LifecycleHandler)
Copyright © 2010–2024. All rights reserved.