首页
随机
最近更改
特殊页面
社群首页
参数设置
关于WHY42
免责声明
WHY42
搜索
用户菜单
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁Blog:关于Event Sourcing架构”︁的源代码
←
Blog:关于Event Sourcing架构
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
在微服务实践中,也许一致性是最头疼的问题了,因为跨数据库的事物将变得十分困难。我们让每一个微服务的数据存储都私有化来实现服务之间的解耦,无可避免存在很多业务需要操作多个微服务的数据库,可能不仅仅是跨服务的不同表,还可能是不同的数据库类型。如果我们采用一个数据库可能事情就会简单了,但这就脱离了微服务的真正价值了。 现阶段解决分布式事物大致有这些方案: * [https://en.wikipedia.org/wiki/Two-phase_commit_protocol 2PC] * [https://en.wikipedia.org/wiki/Three-phase_commit_protocol 3PC] * [https://en.wikipedia.org/wiki/Paxos_(computer_science Paxos])和[https://raft.github.io/ Raft] * [http://cdn.ttgtmedia.com/searchWebServices/downloads/Business_Activities.pdf TCC] 姑且不论实现的复杂性,以上方案大多数可以实现[https://en.wikipedia.org/wiki/Eventual_consistency 最终一致性]。为什么说大多呢?因为太复杂了,我还没研究清楚... 而Event Sourcing目测是一个更简单的实现最终一致性的方案,采用Event Sourcing + CQRS来实现读写分离,具体是什么关系呢?这里引用一点: >在CQRS中,查询方面,直接通过方法查询数据库,然后通过DTO将数据返回。在操作(Command)方面,是通过发送Command实现,由CommandBus处理特定的Command,然后由Command将特定的Event发布到EventBus上,然后EventBus使用特定的Handler来处理事件,执行一些诸如,修改,删除,更新等操作。这里,所有与Command相关的操作都通过Event实现。这样我们可以通过记录Event来记录系统的运行历史记录,并且能够方便的回滚到某一历史状态。Event Sourcing就是用来进行存储和管理事件的。 再来看一张图: [[File:https://www.codeproject.com/KB/architecture/555855/CQRS.jpg|600px|CQRS]] 参考文章: * [https://mp.weixin.qq.com/s?__biz=MzA5Nzc4OTA1Mw==&mid=2659597948&idx=1&sn=754df1597fd042537be8c25d073d3c98&scene=0#rd 基于Event Sourcing和DSL的积分规则引擎设计实现案例 ] * [https://www.nginx.com/blog/event-driven-data-management-microservices/ Event-Driven Data Management for Microservices] * [https://en.wikipedia.org/wiki/CAP_theorem CAP] * [https://martinfowler.com/eaaDev/EventNarrative.html Focusing on Events] * [https://www.martinfowler.com/eaaDev/RetroactiveEvent.html Retroactive Event] * [https://www.martinfowler.com/eaaDev/DomainEvent.html Domain Event] * [https://github.com/cer/event-sourcing-examples Event-Sourcing+CQRS example application] * [http://kb.cnblogs.com/page/161050/ 领域驱动设计(Domain Driven Design)参考架构详解] * [http://codebetter.com/gregyoung/2010/02/16/cqrs-task-based-uis-event-sourcing-agh/ CQRS, Task Based UIs, Event Sourcing agh!] * [www.codeproject.com/Articles/555855/Introduction-to-CQRS Introduction to CQRS] * [https://ookami86.github.io/event-sourcing-in-practice/ Event Sourcing in practice] * [http://thinkbeforecoding.com/post/2013/07/28/Event-Sourcing-vs-Command-Sourcing Event Sourcing vs Command Sourcing]
返回
Blog:关于Event Sourcing架构
。