Home > Net >  How to track changes in mongodb from springboot application
How to track changes in mongodb from springboot application

Time:08-11

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

CodePudding user response:

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.

CodePudding user response:

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

CodePudding user response:

Be more specific. Don’t understand the whole question

  • Related