Class LegacyDbSchedulerDeadlineManagerAutoConfiguration

java.lang.Object
org.axonframework.extension.springboot.autoconfig.LegacyDbSchedulerDeadlineManagerAutoConfiguration

@AutoConfiguration(afterName="com.github.kagkarlsson.scheduler.boot.autoconfigure.DbSchedulerAutoConfiguration") @ConditionalOnClass({com.github.kagkarlsson.scheduler.Scheduler.class,DbSchedulerDeadlineManager.class}) public class LegacyDbSchedulerDeadlineManagerAutoConfiguration extends Object
Auto-configures a DbSchedulerDeadlineManager when the application has a db-scheduler Scheduler, as Axon Framework 4's Spring Boot auto-configuration did.

The manager stores deadlines as DbSchedulerBinaryDeadlineDetails, and this configuration provides the deadlineDetailsTask that executes them, which db-scheduler's own Spring Boot auto-configuration registers with the scheduler. The manager converts the deadlines with the EventConverter, the counterpart of the event serializer Axon Framework 4 wired, so that deadlines an Axon Framework 4 application scheduled keep firing. A fired deadline runs in a unit of work from the configuration's default UnitOfWorkFactory, and is delivered through the configuration's ScopeAwareProvider, with which the Saga managers register themselves.

The scheduler's lifecycle stays with db-scheduler's auto-configuration, which starts the scheduler as soon as it creates it, unless db-scheduler.delay-startup-until-context-ready is set. Deadlines that are overdue by then wait until Axon has started its event processors, as the ScopeAwareProvider only provides the Saga managers once these are built. Set the property to start the scheduler after Axon instead.

Define a DeadlineManager bean to configure the manager differently, for example with another converter. This is needed, for example, when running a DeadlineManager in an upgrade scenario with an XStream-based serializer in Axon Framework 4.

Since:
5.4.0
Author:
Jakob Hatzl
  • Constructor Details

    • LegacyDbSchedulerDeadlineManagerAutoConfiguration

      public LegacyDbSchedulerDeadlineManagerAutoConfiguration()
  • Method Details

    • dbSchedulerDeadlineDetailsTask

      @Bean(name="deadlineDetailsTask") @ConditionalOnMissingQualifiedBean(beanClass=com.github.kagkarlsson.scheduler.task.Task.class, qualifier="deadlineDetailsTask") public com.github.kagkarlsson.scheduler.task.Task<DbSchedulerBinaryDeadlineDetails> dbSchedulerDeadlineDetailsTask(org.springframework.context.ApplicationContext context)
      Creates the task executing the deadlines the DbSchedulerDeadlineManager stores, unless the application defines a Task bean named or qualified deadlineDetailsTask, as Axon Framework 4 applications overriding this task did. The task resolves the manager when a deadline fires.
      Parameters:
      context - the application context to resolve the DbSchedulerDeadlineManager from
      Returns:
      the task executing deadlines
    • deadlineManager

      @Bean @ConditionalOnBean(com.github.kagkarlsson.scheduler.Scheduler.class) @ConditionalOnMissingBean(DeadlineManager.class) public DbSchedulerDeadlineManager deadlineManager(com.github.kagkarlsson.scheduler.Scheduler scheduler, ScopeAwareProvider scopeAwareProvider, Configuration configuration, EventConverter eventConverter)
      Creates the DbSchedulerDeadlineManager, unless the application defines its own DeadlineManager. The manager neither starts nor stops the scheduler, as db-scheduler's Spring Boot auto-configuration does.
      Parameters:
      scheduler - the db-scheduler scheduler storing and firing the deadlines
      scopeAwareProvider - the configuration's provider of the components a fired deadline is delivered to
      configuration - the Axon configuration, providing the default UnitOfWorkFactory, the factory of the unit of work a fired deadline runs in
      eventConverter - the converter of the stored deadlines
      Returns:
      the db-scheduler deadline manager