N
N
Nastya19202020-11-30 12:34:38
MongoDB
Nastya1920, 2020-11-30 12:34:38

Is the @Transaction annotation enough to transact persist across two Mongo databases?

We use spring boot, I work with Mongo recently, through a cluster on mongo atlas.
I know that since version 4.2, it seems like the transaction option has been added.
I have a method that should save data to 2 mongo dbs (in native service and send a save request to db to another service). It is fundamentally important that the data was stored in both databases. Otherwise you need a rollback.
Question: Will @transactional work for such a method? And do I need to explicitly register the mongo bins (or is boot autoconfiguration sufficient)?
Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question