Why Spring Data r2dbc not detecting Transaction manager by method return type when using @Transactional annotation?

Viewed 452

In my project we need to use 2 transaction managers(for JPA and R2DBC), both of them are initialized with auto-configuration(two beans with names transactionManager and connectionFactoryTransactionManager), documentation(link) says that:

Methods returning a reactive type such as Publisher or Kotlin Flow (or a subtype of those) qualify for reactive transaction management.

But actually is not true, spring fails with exception message: No qualifying bean of type 'org.springframework.transaction.TransactionManager' available: expected single matching bean but found 2: transactionManager,connectionFactoryTransactionManager

When I analyzed the code, the main logic detecting which tx manager to use is located in TransactionAspectSupport.determineTransactionManager

but unfortunately this logic not detecting tx manager by methods returning type, as it says the documentation. Well, as a workaround I can choose which tx manager to use explicitly in "@Transactional" annotation. This logic(auto detection of which tx manager to use depending on method return value) is not implemented yet, or I'm doing something wrong?

0 Answers
Related