public class QuartzEventScheduler extends Object implements EventScheduler
EventJobDataBinder
,
FireEventJob
Modifier and Type | Class and Description |
---|---|
static class |
QuartzEventScheduler.Builder
Builder class to instantiate a
QuartzEventScheduler . |
static class |
QuartzEventScheduler.DirectEventJobDataBinder
|
Modifier | Constructor and Description |
---|---|
protected |
QuartzEventScheduler(QuartzEventScheduler.Builder builder)
Instantiate a
QuartzEventScheduler based on the fields contained in the QuartzEventScheduler.Builder . |
Modifier and Type | Method and Description |
---|---|
static QuartzEventScheduler.Builder |
builder()
Instantiate a Builder to be able to create a
QuartzEventScheduler . |
protected org.quartz.JobDetail |
buildJobDetail(EventMessage event,
org.quartz.JobKey jobKey)
Builds the JobDetail instance for Quartz, which defines the Job that needs to be executed when the trigger
fires.
|
protected org.quartz.Trigger |
buildTrigger(Instant triggerDateTime,
org.quartz.JobKey jobKey)
Builds a Trigger which fires the Job identified by
jobKey at (or around) the given
triggerDateTime . |
void |
cancelSchedule(ScheduleToken scheduleToken)
Cancel the publication of a scheduled event.
|
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 |
setGroupIdentifier(String groupIdentifier)
Sets the group identifier to use when scheduling jobs with Quartz.
|
void |
shutdown()
Shuts down this event scheduler.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
reschedule, reschedule
protected QuartzEventScheduler(QuartzEventScheduler.Builder builder)
QuartzEventScheduler
based on the fields contained in the QuartzEventScheduler.Builder
.
Will assert that the Scheduler
, EventBus
, EventJobDataBinder
and
TransactionManager
are not null
, and will throw an AxonConfigurationException
if any of
them is null
.
The EventBus, TransactionManager and EventJobDataBinder will be tied to the Scheduler's context. If this
initialization step fails, this will too result in an AxonConfigurationException.
builder
- the QuartzEventScheduler.Builder
used to instantiate a QuartzEventScheduler
instancepublic static QuartzEventScheduler.Builder builder()
QuartzEventScheduler
.
The EventJobDataBinder
is defaulted to an QuartzEventScheduler.DirectEventJobDataBinder
, and the
TransactionManager
defaults to a NoTransactionManager
.
The Scheduler
and EventBus
are a hard requirements and as such should be provided.
QuartzEventScheduler
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 publishprotected org.quartz.JobDetail buildJobDetail(EventMessage event, org.quartz.JobKey jobKey)
jobKey
and represent a Job that dispatches
the given event
.
This method may be safely overridden to change behavior. Defaults to a JobDetail to fire a FireEventJob
.event
- The event to be scheduled for dispatchjobKey
- The key of the Job to scheduleprotected org.quartz.Trigger buildTrigger(Instant triggerDateTime, org.quartz.JobKey jobKey)
jobKey
at (or around) the given
triggerDateTime
.triggerDateTime
- The time at which a trigger was requestedjobKey
- The key of the job to be triggeredjobKey
public 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 setGroupIdentifier(String groupIdentifier)
groupIdentifier
- the group identifier to use when scheduling jobs with Quartz@ShutdownHandler(phase=1073741823) public void shutdown()
Will shutdown in the Phase.INBOUND_EVENT_CONNECTORS
phase.
shutdown
in interface EventScheduler
Copyright © 2010–2020. All rights reserved.