-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Publish event for @TransactionalEventListener
with Spring WebFlux
#27515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As of 6.1,
Or via the new
|
It's also possible to use the For example in kotlin: @Transactional
suspend fun performSomething() {
userRepository.register()
val manager = TransactionSynchronizationManager.forCurrentTransaction().awaitSingle()
manager.registerSynchronization(object : TransactionSynchronization {
override fun afterCommit(): Mono<Void> = mono {
sendEmail()
}
})
} Or similar in Java: @Transactional
public void performSomething() {
userRepository.register();
TransactionSynchronization transactionSynchronization =
TransactionSynchronizationManager.forCurrentTransaction();
if (transactionSynchronization != null) {
transactionSynchronization.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
sendEmail();
}
});
}
} |
@TransactionalEventListener
with Spring WebFlux
Affects: <Spring Framework 5.3.10>
Spring webflux does not support @TransactionalEventListener to publish event after transaction completed. So what i need to do to publish event only when transaction completed in Spring webflux?
The text was updated successfully, but these errors were encountered: