How to handle transaction management in Solr using Solrj? There is not much documentation related to this on the net. But I would appreciate if someone can provide any links or information related to transaction management using SolrJ.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You would have to programatically deal with the transactions in SolrJ. When dealing with multiple writes.
- Use the SolrServer api add method to add the SolrInputDoucments to the server.
- When all the SolrInputDocuments are added, call the commit method from the SolrServer api to commit all the changes.
- In case of an exception from Solr, if you want to rollback the writes to the Solr, Call the SolServer api rollback method.
- If you want to rollback the writes to the database as well, just throw back a runtime-exception from the catch block.
This is how I dealt with the transaction management. If anyone has better answers, please feel free to improve the answer.