简体   繁体   中英

How to track changes in mongodb from springboot application

I am inserting some data to mongo with springboot application, after that I send this data to kafka. I want to be sure that before I send them to kafka they are commited to mongo. Is there a way I can ensure that this data is commited before sending them to kafka? Thank you

MongoDB 4 supports transactions https://spring.io/blog/2018/06/28/hands-on-mongodb-4-0-transactions-with-spring-data If using this version then you can have commit and rollback.

Earlier MongoDB doesn't support the transaction, so your spring Mongorepository insert call will return after a successful insert. Why do you need to check for commit?

If want to make sure then read that document by ID.

Simply don't do two-phase commits.

Use external processes like Debezium or Mongo Kafka Source Connector to read the data directly from Mongo into Kafka topics

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM