I have a java program, I want to insert data into oracle db and solr at the same time. How can I make sure that data in the db and solr are consistent?
-
1You could make them eventually consistent. stackoverflow.com/questions/12966489/…joshp– joshp2018年06月05日 03:01:34 +00:00Commented Jun 5, 2018 at 3:01
2 Answers 2
Knowing nothing about Solr, I'll assume it's non-transactional.
In that case, start a transaction in Oracle database and make changes. Then make the matching changes in Solr. If the Solr changes succeed, commit the Oracle transaction; if not, roll it back.
It's not perfect by any means but you're using the transactional strength of one element to make up for the deficiencies of the other.
You would have to update one in a transaction and, while the transaction is still active, update the other. If both succeed then commit the transaction. If either the first or second fail, roll back the transaction.