How to save entity and send kafka event transactionally with spring webflux?

Viewed 56

I have

Mono<Response> getResponse(...);

I need to update Data data with field from Mono then save data in DB and then send DTO (containing data and response) to kafka topic in a single transaction.

getResponse(..)
    .map(
          r -> Data.builder().field(r.getField().build()
     )
    .flatMap(repository::save)
    .doOnNext(kafkaClient::sendEvent);

The question is - does this wrapped in a @Transactional method, executes as a single TX (repo save and kafka send)?

0 Answers
Related