Search code examples
databasedesign-patternstransactionsrabbitmqrollback

Database transaction handling for business domain


We have business use cases were a single business use case will have,

Read - write - write - read - write etc

In essence it is a mix of read and write calls, however either all the writes should work or none at all (as in rollback all the successful writes till the failed write)

Our system is as follows

DB module - rabbitmq - database

Currently the DB module has a CRUD DAO per table. It offers a single API that takes the table name, operation and changes as inputs, creates a json and gives it to Rabbitmq .

What design patterns / known solutions are there to handle this scenario of transaction handling and rollback. When I googled I find most solutions for the SQL world which we are not using.

Any help will be great.

Thanks!


Solution

  • Martin Fowler says about Unit of work:

    Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems.

    And:

    A Unit of Work keeps track of everything you do during a business transaction that can affect the database. When you're done, it figures out everything that needs to be done to alter the database as a result of your work.

    It seems like a perfect match for your scenario!