Skip to content

Application Does Not Start When Multiple TransactionManager Bean Exist #2801

@NYPD

Description

@NYPD

Expected Behavior

Spring Session with JDBC supports declaring a datasource with the use of the @SpringSessionDataSource annotation to tell Spring Session which datasource to use. However, if an application has multiple transaction managers, there is no way to tell Spring Session which one to pick directly and has to be done with declaring the bean as "Primary". It would be nice if there was a @SpringSessionTransactionManager to use instead.

Current Behavior

With applications that have multiple transaction managers setting one of them as "primary" is needed even if one does not wish to set it primary.

@Bean
public PlatformTransactionManager transactionManager1(DataSource mainAppDatasource) {
    return new DataSourceTransactionManager(mainAppDatasource); 
}

@Bean
@Primary
public PlatformTransactionManager transactionManager2(DataSource springSessionDatasource) {
     return new DataSourceTransactionManager(springSessionDatasource); 
}

Context

I have inherited a application that contains 4 JDBC datasources, each with their own transaction managers. Incorporating Spring Session can only be done with making one of them primary.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions