Class QuartzEventScheduler
java.lang.Object
org.axonframework.eventhandling.scheduling.quartz.QuartzEventScheduler
- All Implemented Interfaces:
EventScheduler,Lifecycle
EventScheduler implementation that delegates scheduling and triggering to a Quartz Scheduler.
- Since:
- 0.7
- Author:
- Allard Buijze
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aQuartzEventScheduler.static classNested classes/interfaces inherited from interface org.axonframework.lifecycle.Lifecycle
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aQuartzEventSchedulerbased on the fields contained in theQuartzEventScheduler.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic QuartzEventScheduler.Builderbuilder()Instantiate a Builder to be able to create aQuartzEventScheduler.protected org.quartz.JobDetailbuildJobDetail(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.TriggerbuildTrigger(Instant triggerDateTime, org.quartz.JobKey jobKey) Builds a Trigger which fires the Job identified byjobKeyat (or around) the giventriggerDateTime.voidcancelSchedule(ScheduleToken scheduleToken) Cancel the publication of a scheduled event.voidRegisters the activities to be executed in the various phases of an application's lifecycle.Schedule the giveneventfor publication after the giventriggerDuration.Schedule the giveneventfor publication at the giventriggerDateTime.voidsetGroupIdentifier(String groupIdentifier) Sets the group identifier to use when scheduling jobs with Quartz.voidshutdown()Shuts down this event scheduler.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.eventhandling.scheduling.EventScheduler
reschedule, reschedule
-
Constructor Details
-
QuartzEventScheduler
Instantiate aQuartzEventSchedulerbased on the fields contained in theQuartzEventScheduler.Builder.Will assert that the
SchedulerandEventBusare notnull, and will throw anAxonConfigurationExceptionif any of them isnull. 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.- Parameters:
builder- theQuartzEventScheduler.Builderused to instantiate aQuartzEventSchedulerinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aQuartzEventScheduler.The
EventJobDataBinderis defaulted to aQuartzEventScheduler.DirectEventJobDataBinderusing the configuredSerializer, and theTransactionManagerdefaults to aNoTransactionManager. Note that if theSerializeris not set, the configuration expects theEventJobDataBinderto be set.The
SchedulerandEventBusare hard requirements and as such should be provided.- Returns:
- a Builder to be able to create a
QuartzEventScheduler
-
schedule
Description copied from interface:EventSchedulerSchedule the giveneventfor publication at the giventriggerDateTime. The returned ScheduleToken can be used to cancel the planned publication. The giveneventmay 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 giveneventwill be wrapped as the payload of an EventMessage.- Specified by:
schedulein interfaceEventScheduler- Parameters:
triggerDateTime- The moment to trigger publication of the eventevent- The event to publish- Returns:
- the token to use when cancelling the schedule
-
buildJobDetail
Builds the JobDetail instance for Quartz, which defines the Job that needs to be executed when the trigger fires. The resulting JobDetail must be identified by the givenjobKeyand represent a Job that dispatches the givenevent. This method may be safely overridden to change behavior. Defaults to a JobDetail to fire aFireEventJob.- Parameters:
event- The event to be scheduled for dispatchjobKey- The key of the Job to schedule- Returns:
- a JobDetail describing the Job to be executed
-
buildTrigger
Builds a Trigger which fires the Job identified byjobKeyat (or around) the giventriggerDateTime.- Parameters:
triggerDateTime- The time at which a trigger was requestedjobKey- The key of the job to be triggered- Returns:
- a configured Trigger for the Job with key
jobKey
-
schedule
Description copied from interface:EventSchedulerSchedule the giveneventfor publication after the giventriggerDuration. The returned ScheduleToken can be used to cancel the planned publication. The giveneventmay 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 giveneventwill be wrapped as the payload of an EventMessage.- Specified by:
schedulein interfaceEventScheduler- Parameters:
triggerDuration- The amount of time to wait before publishing the eventevent- The event to publish- Returns:
- the token to use when cancelling the schedule
-
cancelSchedule
Description copied from interface:EventSchedulerCancel the publication of a scheduled event. If the events has already been published, this method does nothing.- Specified by:
cancelSchedulein interfaceEventScheduler- Parameters:
scheduleToken- the token returned when the event was scheduled
-
setGroupIdentifier
Sets the group identifier to use when scheduling jobs with Quartz. Defaults to "AxonFramework-Events".- Parameters:
groupIdentifier- the group identifier to use when scheduling jobs with Quartz
-
registerLifecycleHandlers
Description copied from interface:LifecycleRegisters the activities to be executed in the various phases of an application's lifecycle. This could either be at startup, shutdown, or both.- Specified by:
registerLifecycleHandlersin interfaceLifecycle- Parameters:
lifecycle- the lifecycle instance to register the handlers with- See Also:
-
shutdown
public void shutdown()Description copied from interface:EventSchedulerShuts down this event scheduler.- Specified by:
shutdownin interfaceEventScheduler
-