业务领域的数据库事务处理

Database transaction handling for business domain

我们有业务用例,单个业务用例会有,

读-写-写-读-写等

本质上它是读取和写入调用的混合,但是要么所有的写入都应该工作,要么 none 根本不工作(如回滚所有成功的写入直到写入失败)

我们的系统如下

数据库模块-rabbitmq-数据库

目前,DB 模块每个 table 都有一个 CRUD DAO。它提供了一个 API 以 table 名称、操作和更改作为输入,创建一个 json 并将其提供给 Rabbitmq 。

有哪些设计模式/已知解决方案可以处理这种事务处理和回滚场景。当我用谷歌搜索时,我找到了我们没有使用的 SQL 世界的大多数解决方案。

任何帮助都会很棒。

谢谢!

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.

并且:

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.

这似乎非常适合您的场景!