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
.
Constructor and Description |
---|
SimpleDeadlineManager(ScopeAwareProvider scopeAwareProvider)
Initializes SimpleDeadlineManager with
scopeAwareProvider which will load and send messages to
Scope implementing components. |
SimpleDeadlineManager(ScopeAwareProvider scopeAwareProvider,
ScheduledExecutorService scheduledExecutorService,
TransactionManager transactionManager)
Initializes a SimpleDeadlineManager to handle the process around scheduling and triggering a
DeadlineMessage |
SimpleDeadlineManager(ScopeAwareProvider scopeAwareProvider,
TransactionManager transactionManager)
Initializes SimpleDeadlineManager with
transactionManager and scopeAwareProvider which will
load and send messages to Scope implementing components. |
Modifier and Type | Method and Description |
---|---|
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. |
void |
schedule(Duration triggerDuration,
String deadlineName,
Object messageOrPayload,
ScopeDescriptor deadlineScope,
String scheduleId)
Schedules a deadline after the given
triggerDuration with provided context. |
runOnPrepareCommitOrNow
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
generateScheduleId, schedule, schedule, schedule, schedule, schedule, schedule, schedule
public SimpleDeadlineManager(ScopeAwareProvider scopeAwareProvider)
scopeAwareProvider
which will load and send messages to
Scope
implementing components. NoTransactionManager
is used as
transaction manager and Executors.newSingleThreadScheduledExecutor()
with AxonThreadFactory
is
used as scheduled executor service.scopeAwareProvider
- a List
of ScopeAware
components which are able to load and send
Messages to components which implement Scope
public SimpleDeadlineManager(ScopeAwareProvider scopeAwareProvider, TransactionManager transactionManager)
transactionManager
and scopeAwareProvider
which will
load and send messages to Scope
implementing components.
Executors.newSingleThreadScheduledExecutor()
with AxonThreadFactory
is used as scheduled executor
service.scopeAwareProvider
- a List
of ScopeAware
components which are able to load and send
Messages to components which implement Scope
transactionManager
- The transaction manager used to manage transaction during processing of DeadlineMessage
when deadline is not metpublic SimpleDeadlineManager(ScopeAwareProvider scopeAwareProvider, ScheduledExecutorService scheduledExecutorService, TransactionManager transactionManager)
DeadlineMessage
scopeAwareProvider
- a List
of ScopeAware
components which are able to load and send
Messages to components which implement Scope
scheduledExecutorService
- Java's service used for scheduling and triggering deadlinestransactionManager
- The transaction manager used to manage transaction during processing of DeadlineMessage
when deadline is not metpublic void schedule(Duration triggerDuration, String deadlineName, Object messageOrPayload, ScopeDescriptor deadlineScope, String scheduleId)
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 scheduledscheduleId
- A String
schedule id to use when cancelling the schedulepublic 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–2018. All rights reserved.