In JdbcTransactionManagerConfiguration, the transactionManager bean is registered if there is no bean of TransactionManager types. However, the autoconfiguration is responsible for jdbc transactionmanagers related with PlatformTransactionManager, not ReactiveTransactionManager. For now, with an existing ReactiveTransactionManager, this autoconfiguration doesn't register the expectable transactionmanager. I think the condition of the transactionManager() bean method should be modified.

I added a test related with it, and fixed one existing test because it didn't configure DataSourceAutoConfiguration, which made the test vacuously true.


After I made this PR, I checked the issue #22851 which is opposite. It said like below.

Considering that framework expects a single bean of that type for unqualified @Transactional use, I think we should refine our auto-configuration to avoid that by default.

I also agreed with it, but I made this PR because when I develop a spring batch application with jdbc for JobRepository and r2dbc for main service and repository logic, I figured out this condition of the autoconfiguration prevents registering the required jdbc transactionmanager. Please give your opinion about this and I can close this PR or modify PR only for fixing the existing test.

Comment From: pivotal-cla

@davin111 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@davin111 Thank you for signing the Contributor License Agreement!

Comment From: snicoll

I can confirm that the transaction auto-configuration is doing this on purpose and having more than one transaction managers is not something we'd expect. You shouldn't mix jdbc and R2DBC in the same app for a similar reason.

Comment From: davin111

@snicoll Do you think having more than one transaction managers should be avoided, even though @Transactional supports the way to specify which transactionManager should be used? I think some apps can have both transactionManagers for some special purposes.

Comment From: snicoll

Yes, and you are right that some apps can have multiple transaction managers. These are meant for multi-ressources transaction management, such as a JMS resource and a JDBC resource. Our auto-configuration should promote the standard way of doing things, which is why this PR was declined.