Does WebFlux Spring Boot @Transactional
annotation work with reactive MongoDB?
I use WebFlux Spring Boot with reactive MongoDB like:
id 'org.springframework.boot' version '2.6.7'
...
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
...
I marked one of my method @Transactional
to test. But it seems the annotation does not work for me. If an error occurs inside this method, then it still adds a row to my mongoDB database.
import org.springframework.transaction.annotation.Transactional;
...
@Transactional
public Mono<Chat> createChat(Chat chat) {
return chatRepository
.save(chat)
.map(
c-> {
if (true) {
throw new RuntimeException();
}
return c;
});
}
Do I miss something or Spring Boot @Transactional
annotation does not work with reactive MongoDB?
I use MongoDB v5.0.8