0

I have a Java Spring 3.0 application that inserts data in a database via myBatis 3.1 and also uses DataImportHandler (DIH) to have Solr 3.6.1 index that database data as well as index binary file attachments. So, I would like to have transaction that rollback changes if any of the following fail:

1) 3 inserts into the database using myBatis

2) solr DIH index of the 3 inserts

3) solr index of binary files

I'm guessing that I need to use JTA since I have multiple datasources but I do not know how to configure with Solr in the mix. How can this be done? Any online references that demonstrate how to accomplish this would also be great. Thanks.

James
  • 2,876
  • 18
  • 72
  • 116

2 Answers2

1

I have asked a Similar Solr transaction management question before. The below links would be helpful.

solr transaction management using solrj

SolrJ Thread Safety

Hope this helps. Good luck!

Community
  • 1
  • 1
Ravi
  • 843
  • 2
  • 15
  • 31
0

you could also try to replace the DIH updates to the index using HttpSolrServer so that you can make use of springs TransactionSynchronizationManager

if (TransactionSynchronizationManager.isSynchronizationActive()) {
  TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
    //... 
  });
}
Christoph Strobl
  • 6,491
  • 25
  • 33