Skip to content

Can't stop a job due to multiple transaction managers #46

Description

@sallampalli

Scenario

  1. Embedded Lightmin approach
  2. Multiple Datasources configured due to functional needs
  3. The primary datasource is configured and fed to Spring batch using DefaultBatchConfigurer
    @Bean BatchConfigurer customBatchConfig() { DefaultBatchConfigurer customBatchConfig = new DefaultBatchConfigurer(primaryDataSource()); return customBatchConfig; }
    This will configure the default transactionManager
  4. The second datasource is configured with JPA so another customTransactionManager is configured to manage the JPA entities

Versions

  • Lightmin 2.1.1
  • Spring Boot 2.2.6.RELEASE

Problem Statement

  1. When I tried stopping a job, got an exception "Could not stop a job" .
  2. I had to run in DEBUG mode to figure out underlying exception, turns out that it is because of multiple transaction managers.
    org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.transaction.TransactionManager' available: expected single matching bean but found 4: transactionManager,customTransactionManager,lightminTransactionManager,lightminServerSchedulerTransactionManager
  3. When a job is stopped, lightmin uses the jobOperator to make an update in the database and it uses @Transacational on that method . Looks like it is not able to figure out which transaction manager to use since it found 4 of them

Question
Is there a way we can tell Lightmin to use the default spring batch config implementation (DefaultBatchConfigurer) instead of its own ? I saw a similar issue couple of years back : #19

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions