Sumit A
Sumit A

Reputation: 180

What is a way to handle transactions over two or more noSQL databases?

We have following requirement:

  1. We are storing data in Cassandra and then we will be indexing the same data (or part of that data) in elastic search.
  2. The issue is if something goes wrong while inserting in elastic search, the data inserted in Cassandra should be rollbacked.

Basically, we want to have transactions over multiple NoSQL databases. Is there a way to do it in Java (Spring)?

Upvotes: 1

Views: 312

Answers (1)

Piyush Katariya
Piyush Katariya

Reputation: 775

There is no standard way of doing transaction across multiple NoSQL databases nor its supported by Spring.

Two approaches comes to my mind:

  1. You should be using only one database to achieve it. for example in your case, You can use Cassandra to do transaction at Node, Data Center or all Data Center level. and send data to Elastic Search asynchronously after Cassandra transaction succeeds

  2. But if you must do it, I would recommend using Redis for acquiring global distributed transaction lock. Note that this is very expensive operation and you need to take care failure and rollback by yourself.

Upvotes: 2

Related Questions