Deadline manager bean with spring boot

Hey Everyone,

I’m having some trouble getting the deadline manager to run, while using spring boot.
I’ve found this solution: DeadlineManager bean definition - Axon Framework - Discuss.AxonIQ
This works, however I need the deadlines to be able to persist.

I’m using axon version 4.9.1 and jobrunr-spring-boot-3-starter 6.3.4.

I started with the deadlinemanager bean, then had to add jobscheduler, then the storageprovider and now it’s asking for the jobmapper bean. I have a feeling this is not the correct way of implementing the deadline manager bean.
Thanks in advance!

I have these beans in my axonconfiguration.java class:

@Bean
public StorageProvider storageProvider(final JobMapper jobMapper) {
    final InMemoryStorageProvider storageProvider = new InMemoryStorageProvider();
    storageProvider.setJobMapper(jobMapper);
    return storageProvider;
}

    @Bean
public JobScheduler JobScheduler(final StorageProvider StorageProvider) {
    return JobRunr.configure()
        .useStorageProvider(StorageProvider)
        .useBackgroundJobServer().initialize().getJobScheduler();
}

@Bean
public DeadlineManager deadlineManager(
    @Qualifier("eventSerializer") final Serializer serializer,
    final JobScheduler jobScheduler,
    final TransactionManager transactionManager,
    final org.axonframework.config.Configuration configuration
) {
    return JobRunrDeadlineManager.builder()
        .jobScheduler(jobScheduler)
        .scopeAwareProvider(configuration.scopeAwareProvider())
        .serializer(serializer)
        .transactionManager(transactionManager)
        .build();
}

Hi Mick,

It should work, with just the jobrunner starter as dependency, it should them auto configure the JobRunrDeadlineManager for you. What do you use as persistence layer? Job runner supports a bunch, but maybe the one you use is not compatible, or not correctly configured for Job Runner. I used it a couple of times with both PostgreSQL and MongoDB, and did not need additional configuration.

we use an oracle sql database, could be that that is not yet configured correctly for the job runner, as this will be the first time using it in the project

There are some related issues, I suspect a table might need to be created, maybe manually.

My colleage was able to find a solution, thought I’d share just in case for anyone else:

@Bean
public DeadlineManager deadlineManager(
    @Qualifier("eventSerializer") final Serializer serializer,
    final TransactionManager transactionManager,
    final org.axonframework.config.Configuration configuration,
    final DataSource dataSource
) {
    return JobRunrDeadlineManager.builder()
        .jobScheduler(new JobScheduler(new OracleStorageProvider(dataSource)))
        .scopeAwareProvider(new ConfigurationScopeAwareProvider(configuration))
        .serializer(serializer)
        .transactionManager(transactionManager)
        .build();
}
1 Like

Just a headsup we improved the configuration to be able to use H2 for integration tests and Oracle for the rest:

@Bean
    @Profile("!test")
    public StorageProvider storageProvider(final DataSource dataSource) {
        return new OracleStorageProvider(dataSource);
    }
 @Bean
    @Profile("test")
    @Qualifier("storageProvider")
    public StorageProvider h2StorageProvider(final DataSource dataSource) {
        return new H2StorageProvider(dataSource);
    }

    @Bean
    public DeadlineManager deadlineManager(
        @Qualifier("eventSerializer") final Serializer serializer,
        final TransactionManager transactionManager,
        final org.axonframework.config.Configuration configuration,
        final StorageProvider storageProvider
    ) {
        return JobRunrDeadlineManager.builder()
            .jobScheduler(new JobScheduler(storageProvider))
            .scopeAwareProvider(new ConfigurationScopeAwareProvider(configuration))
            .serializer(serializer)
            .transactionManager(transactionManager)
            .build();
    }