public class SimpleDeadlineManager extends AbstractDeadlineManager
DeadlineManager
which uses Java's ScheduledExecutorService
as scheduling and
triggering mechanism.
Note that this mechanism is non-persistent. Scheduled tasks will be lost then the JVM is shut down, unless special
measures have been taken to prevent that. For more flexible and powerful scheduling options, see QuartzDeadlineManager
.
Modifier and Type | Class and Description |
---|---|
static class |
SimpleDeadlineManager.Builder
Builder class to instantiate a
SimpleDeadlineManager . |
Modifier | Constructor and Description |
---|---|
protected |
SimpleDeadlineManager(SimpleDeadlineManager.Builder builder)
Instantiate a
SimpleDeadlineManager based on the fields contained in the SimpleDeadlineManager.Builder to handle the
process around scheduling and triggering a DeadlineMessage . |
Modifier and Type | Method and Description |
---|---|
static SimpleDeadlineManager.Builder |
builder()
Instantiate a Builder to be able to create a
SimpleDeadlineManager . |
void |
cancelAll(String deadlineName)
Cancels all the deadlines corresponding to the given
deadlineName . |
void |
cancelSchedule(String deadlineName,
String scheduleId)
Cancels the deadline corresponding to the given
deadlineName / scheduleId combination. |
String |
schedule(Duration triggerDuration,
String deadlineName,
Object messageOrPayload,
ScopeDescriptor deadlineScope)
Schedules a deadline after the given
triggerDuration with provided context. |
dispatchInterceptors, handlerInterceptors, processDispatchInterceptors, registerDispatchInterceptor, registerHandlerInterceptor, runOnPrepareCommitOrNow
protected SimpleDeadlineManager(SimpleDeadlineManager.Builder builder)
SimpleDeadlineManager
based on the fields contained in the SimpleDeadlineManager.Builder
to handle the
process around scheduling and triggering a DeadlineMessage
.
Will assert that the ScopeAwareProvider
, ScheduledExecutorService
and TransactionManager
are not null
, and will throw an AxonConfigurationException
if either of them is null
.
builder
- the SimpleDeadlineManager.Builder
used to instantiate a SimpleDeadlineManager
instancepublic static SimpleDeadlineManager.Builder builder()
SimpleDeadlineManager
.
The ScheduledExecutorService
is defaulted to an Executors.newSingleThreadScheduledExecutor()
which contains an AxonThreadFactory
, and the TransactionManager
defaults to a
NoTransactionManager
. The ScopeAwareProvider
is a hard requirement and as such should be
provided.
SimpleDeadlineManager
public String schedule(Duration triggerDuration, String deadlineName, Object messageOrPayload, ScopeDescriptor deadlineScope)
DeadlineManager
triggerDuration
with provided context. The provided
deadlineName
/ scheduleId
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
.
Scheduling a deadline with the same deadlineName
and scheduleId
will replace the previous
schedule with the new one.
triggerDuration
- A Duration
describing the waiting period before handling the deadlinedeadlineName
- 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 scheduledpublic void cancelSchedule(String deadlineName, String scheduleId)
DeadlineManager
deadlineName
/ scheduleId
combination.
This method has no impact on deadlines which have already been triggered.public void cancelAll(String deadlineName)
DeadlineManager
deadlineName
.
This method has no impact on deadlines which have already been triggered.deadlineName
- A String
representing the name of the deadlines to cancelCopyright © 2010–2019. All rights reserved.