When implementing a Spring Boot application with multiple data sources and therefore transaction managers, I want to easily configure the correct transaction manager that the Camunda Spring Boot Starter should use.
For data sources, we have the following pattern (https://docs.camunda.org/manual/7.12/user-guide/spring-boot-integration/configuration/#defaultdatasourceconfiguration):
- If present, a data source named camundaBpmDataSource is used
- Else the @Primary data source is used
For transaction managers, we currently always use the @Primary one. Since data source and tx manager must be configured consistently (
CAM-11270), it would be helpful if a dedicated named Camunda tx manager (e.g. camundaBpmTransactionManager) can be used. That way users do not have to a) use the primary tx manager for Camunda or b) write more complex code to configure a secondary tx manager with Camunda (e.g. overriding the entire data source configuration class).
- If users declare a bean named camundaBpmTransactionManager of type PlatformTransactionManager, then that bean is automatically wired with the DefaultDatasourceConfiguration (https://github.com/camunda/camunda-bpm-platform/blob/master/spring-boot-starter/starter/src/main/java/org/camunda/bpm/spring/boot/starter/configuration/impl/DefaultDatasourceConfiguration.java) in the Camunda Spring Boot starter