-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Scenario
- Embedded Lightmin approach
- Multiple Datasources configured due to functional needs
- 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 - 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
- When I tried stopping a job, got an exception "Could not stop a job" .
- 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 - 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
toneeraj