public class QuartzEventScheduler extends Object implements EventScheduler
EventJobDataBinder
,
FireEventJob
Modifier and Type | Class and Description |
---|---|
static class |
QuartzEventScheduler.DirectEventJobDataBinder
Binds the
EventMessage as is to JobDataMap under QuartzEventScheduler.DirectEventJobDataBinder.EVENT_KEY . |
Constructor and Description |
---|
QuartzEventScheduler() |
Modifier and Type | Method and Description |
---|---|
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.
|
void |
initialize()
Initializes the QuartzEventScheduler.
|
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 |
setEventBus(EventBus eventBus)
Sets the event bus to which scheduled events need to be published.
|
void |
setEventJobDataBinder(EventJobDataBinder jobDataBinder)
Sets the
EventJobDataBinder instance which reads / writes the event message to publish to the
JobDataMap . |
void |
setGroupIdentifier(String groupIdentifier)
Sets the group identifier to use when scheduling jobs with Quartz.
|
void |
setScheduler(org.quartz.Scheduler scheduler)
Sets the backing Quartz Scheduler for this timer.
|
void |
setTransactionManager(TransactionManager transactionManager)
Sets the transaction manager that manages a transaction around the publication of an event.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
reschedule
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 scheduled@PostConstruct public void initialize() throws org.quartz.SchedulerException
EventBus
available to the Quartz Scheduler.org.quartz.SchedulerException
- if an error occurs preparing the Quartz Scheduler for use.public void setScheduler(org.quartz.Scheduler scheduler)
scheduler
- the backing Quartz Scheduler for this timerpublic void setEventBus(EventBus eventBus)
eventBus
- the event bus to which scheduled events need to be published.public void setGroupIdentifier(String groupIdentifier)
groupIdentifier
- the group identifier to use when scheduling jobs with Quartzpublic void setTransactionManager(TransactionManager transactionManager)
transactionManager
- the callback to invoke before and after publication of a scheduled eventpublic void setEventJobDataBinder(EventJobDataBinder jobDataBinder)
EventJobDataBinder
instance which reads / writes the event message to publish to the
JobDataMap
. Defaults to QuartzEventScheduler.DirectEventJobDataBinder
.jobDataBinder
- to useCopyright © 2010–2017. All rights reserved.