Skip to content

Consider target transaction manager for traditional vs reactive transaction decision #23832

Closed
@dittos

Description

@dittos

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)?

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions