EventSchedulerfor dealing with deadlines.
EventSchedulerto schedule an event for publication. In the example of an invoice, you would expect the invoice to be paid within thirty days. A saga would, after sending the
CreateInvoiceCommand, schedule an
InvoicePaymentDeadlineExpiredEventto be published in 30 days. The
ScheduleTokenafter scheduling an event. This token can be used to cancel the schedule, for example when a payment of an Invoice has been received.
ScheduledExecutorServiceto schedule event publication. Although the timing of this scheduler is very reliable, it is a pure in-memory implementation. Once the JVM is shut down, all schedules are lost. This makes this implementation unsuitable for long-term schedules. The
SimpleEventSchedulerneeds to be configured with an
SchedulingExecutorService(see the static methods on the
java.util.concurrent.Executorsclass for helper methods).
QuartzEventScheduleris a more reliable and enterprise-worthy implementation. Using Quartz as underlying scheduling mechanism, it provides more powerful features, such as persistence, clustering and misfire management. This means event publication is guaranteed. It might be a little late, but it will be published. It needs to be configured with a Quartz
EventBus. Optionally, you may set the name of the group that Quartz jobs are scheduled in, which defaults to
AxonServerEventScheduleruses Axon Server to schedule events for publication. As such, it is a hard requirement to use Axon Server as your Event Store solution to utilize this event scheduler. Just as the
AxonServerEventScheduleris a reliable and enterprise-worthy implementation of the
EventSchedulerinterface. Creating a
AxonServerEventSchedulercan be done through its builder, whose sole requirement is the
AxonServerEventSchedulershould use the event
Serializerto serialize and deserialize the scheduled event. If the
Serializerused by the scheduler does not align with the
Seralizerused by the event store, exceptional scenarios should be expected. The Quartz implementation's
Serializercan be set by defining a different
EventJobDataBinder, whereas the Axon Server implementation allows defining the used
Serializerdirectly through the builder.
EventScheduler. To manage transactions on these threads, you can configure a
UnitOfWorkFactorythat creates a transaction bound unit of work.
Spring ConfigurationSpring users can use the
SimpleEventSchedulerFactoryBeanfor easier configuration. It allows you to set the
PlatformTransactionManagerdirectly.Spring Boot users which rely on Axon Server do not have to define anything. The auto configuration will automatically create a