public class DbSchedulerEventScheduler extends Object implements EventScheduler, Lifecycle
Modifier and Type | Class and Description |
---|---|
static class |
DbSchedulerEventScheduler.Builder
Builder class to instantiate a
DbSchedulerEventScheduler . |
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry
Modifier | Constructor and Description |
---|---|
protected |
DbSchedulerEventScheduler(DbSchedulerEventScheduler.Builder builder)
Instantiate a
DbSchedulerEventScheduler based on the fields contained in the
DbSchedulerEventScheduler.Builder . |
Modifier and Type | Method and Description |
---|---|
static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerBinaryEventData> |
binaryTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier)
|
static DbSchedulerEventScheduler.Builder |
builder()
Instantiate a Builder to be able to create a
DbSchedulerEventScheduler . |
void |
cancelSchedule(ScheduleToken scheduleToken)
Cancel the publication of a scheduled event.
|
static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerHumanReadableEventData> |
humanReadableTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier)
|
void |
registerLifecycleHandlers(Lifecycle.LifecycleRegistry lifecycle)
Registers the activities to be executed in the various phases of an application's lifecycle.
|
ScheduleToken |
schedule(Duration triggerDuration,
Object event)
Schedule the given
event for publication after the given triggerDuration . |
ScheduleToken |
schedule(Instant triggerDateTime,
Object event)
Schedule the given
event for publication at the given triggerDateTime . |
void |
shutdown()
Shuts down this event scheduler.
|
void |
start()
Will start the
Scheduler depending on its current state and the value of startScheduler , |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
reschedule, reschedule
protected DbSchedulerEventScheduler(DbSchedulerEventScheduler.Builder builder)
DbSchedulerEventScheduler
based on the fields contained in the
DbSchedulerEventScheduler.Builder
.
Will assert that the Scheduler
, Serializer
and EventBus
are not null
, and will
throw an AxonConfigurationException
if any of them is null
.
builder
- the DbSchedulerEventScheduler.Builder
used to instantiate a DbSchedulerEventScheduler
instancepublic static DbSchedulerEventScheduler.Builder builder()
DbSchedulerEventScheduler
.
The TransactionManager
is defaulted to a NoTransactionManager
. The useBinaryPojo
is
defaulted to true
.
The Scheduler
, Serializer
and EventBus
are hard requirements and as such should be
provided.
DbSchedulerEventScheduler
public ScheduleToken schedule(Instant triggerDateTime, Object event)
EventScheduler
event
for publication at the given triggerDateTime
. The returned
ScheduleToken can be used to cancel the planned publication.
The given event
may 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 given event
will be wrapped as the payload of an EventMessage.schedule
in interface EventScheduler
triggerDateTime
- The moment to trigger publication of the eventevent
- The event to publishpublic static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerHumanReadableEventData> humanReadableTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier)
Task
using DbSchedulerBinaryEventData
to publish an event via a Scheduler
. To
be able to execute the task, this should be added to the task list, used to create the scheduler.eventSchedulerSupplier
- a Supplier
of a DbSchedulerEventScheduler
. Preferably a method
involving dependency injection is used. When those are not available the
DbSchedulerEventSchedulerSupplier
can be used instead.Task
to publish an eventpublic static com.github.kagkarlsson.scheduler.task.Task<DbSchedulerBinaryEventData> binaryTask(Supplier<DbSchedulerEventScheduler> eventSchedulerSupplier)
Task
using DbSchedulerHumanReadableEventData
to publish an event via a
Scheduler
. To be able to execute the task, this should be added to the task list, used to create the
scheduler.eventSchedulerSupplier
- a Supplier
of a DbSchedulerEventScheduler
. Preferably a method
involving dependency injection is used. When those are not available the
DbSchedulerEventSchedulerSupplier
can be used instead.Task
to publish an eventpublic ScheduleToken schedule(Duration triggerDuration, Object event)
EventScheduler
event
for publication after the given triggerDuration
. The
returned ScheduleToken can be used to cancel the planned publication.
The given event
may 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 given event
will be wrapped as the payload of an EventMessage.schedule
in interface EventScheduler
triggerDuration
- The amount of time to wait before publishing the eventevent
- The event to publishpublic void cancelSchedule(ScheduleToken scheduleToken)
EventScheduler
cancelSchedule
in interface EventScheduler
scheduleToken
- the token returned when the event was scheduledpublic void start()
Scheduler
depending on its current state and the value of startScheduler
,public void shutdown()
EventScheduler
shutdown
in interface EventScheduler
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.