Closed
Description
In our app, we have several controller methods that construct Mono
within JPA transaction and returns it.
Something like:
@PostMapping
@Transactional
fun handle(): Mono<Boolean> {
val user = findUser()
val subscription = user.subscriptions[0]
return emailSender.send(subscription.email, ...)
}
Before 5.2, the transaction commits when the method returns, and the returned side effect gets executed without holding a transaction.
With reactive transactions introduced in 5.2, code like this breaks because JpaTransactionManager
is not a ReactiveTransactionManager
.
Currently there is no way to restore the previous behavior as reactive transaction handling is always active in TransactionAspectSupport. It would be easier to upgrade if there is a way to opt-out from reactive transaction behavior.
Some ideas:
- Globally disable reactive transactions:
TransactionAspectSupport#setEnableReactiveTransactions(false)
? - Selectively disable reactive transactions:
@Transactional(reactive = false)
?