cqrs

How to handle set based consistency validation in CQRS?

一曲冷凌霜 提交于 2019-11-27 07:15:51
I have a fairly simple domain model involving a list of Facility aggregate roots. Given that I'm using CQRS and an event-bus to handle events raised from the domain, how could you handle validation on sets? For example, say I have the following requirement: Facility 's must have a unique name. Since I'm using an eventually consistent database on the query side, the data in it is not guaranteed to be accurate at the time the event processesor processes the event. For example, a FacilityCreatedEvent is in the query database event processing queue waiting to be processed and written into the

Using an RDBMS as event sourcing storage

孤者浪人 提交于 2019-11-27 04:57:18
问题 If I were using an RDBMS (e.g. SQL Server) to store event sourcing data, what might the schema look like? I've seen a few variations talked about in an abstract sense, but nothing concrete. For example, say one has a "Product" entity, and changes to that product could come in the form of: Price, Cost and Description. I'm confused about whether I'd: Have a "ProductEvent" table, that has all the fields for a product, where each change means a new record in that table, plus "who, what, where,

Multiple Aggregates / Repositories in one Transaction

有些话、适合烂在心里 提交于 2019-11-27 00:41:01
I have a payment system as shown below. The payment can be made through multiple gift coupons. The gift coupons are issued along with a purchase. The customer can make use of this gift coupon for future purchase. When a Payment is made through gift coupon, the UsedForPaymentID column in GiftCoupon table need to be updated with that PaymentID (for the giftcoupon ID). The GiftCouponIDs are already available in the database. When a customer produces a gift coupon, it has GiftCouponID printed on it. The operator need to enter this CouponID to the system to make the Payment. For the MakePayment()

Communicating between two Bounded Contexts in DDD

落花浮王杯 提交于 2019-11-27 00:33:17
I have few different Bounded Contexts in the domain. The validation of a CRUD operation is built in each Bounded Context. For example, I can create an entity called GAME only if the person creating it is a Group Leader . I have two Bounded Contexts (BC) in this example. One is the Game BC and the other is the User BC . To solve the problem, in the Game BC , I have to make a domain service call like IsGroupLeader() to the User BC before proceeding on creating the Game. I don't think this type of communication is recommended by DDD. I can have a User entity also in the Game BC , but I don't want

[转]浅谈命令查询职责分离(CQRS)模式

戏子无情 提交于 2019-11-26 19:32:10
在常用的三层架构中,通常都是通过数据访问层来修改或者查询数据,一般修改和查询使用的是相同的实体。在一些业务逻辑简单的系统中可能没有什么问题,但是随着系统逻辑变得复杂,用户增多,这种设计就会出现一些性能问题。虽然在DB上可以做一些读写分离的设计,但在业务上如果在读写方面混合在一起的话,仍然会出现一些问题。 本文介绍了命令查询职责分离模式(Command Query Responsibility Segregation,CQRS),该模式从业务上分离修改 (Command,增,删,改,会对系统状态进行修改)和查询(Query,查,不会对系统状态进行修改)的行为。从而使得逻辑更加清晰,便于对不同部分进行针对性的优化。文章首先简要介绍了传统的CRUD方式存在的问题,接着介绍了CQRS模式,最后以一个简单的在线日记系统演示了如何实现CQRS模式。要谈到读写操作,首先我们来看传统的CRUD的问题。 一 CRUD方式的问题 在以前的管理系统中,命令(Command,通常用来更新数据,操作DB)和查询(Query)通常使用的是在数据访问层中Repository中的实体对象(这些对象是对DB中表的映射),这些实体有可能是SQLServer中的一行数据或者多个表。 通常对DB执行的增,删,改,查(CRUD)都是针对的系统的实体对象。如通过数据访问层获取数据,然后通过数据传输对象DTO传给表现层。或者

Using Kafka as a (CQRS) Eventstore. Good idea?

眉间皱痕 提交于 2019-11-26 16:52:16
Although I've come across Kafka before, I just recently realized Kafka may perhaps be used as (the basis of) a CQRS , eventstore . One of the main points that Kafka supports: Event capturing / storing, all HA of course. Pub / sub architecture Ability to replay the eventlog which allows the ability for new subscribers to register with the system after the fact. Admittedly I'm not 100% versed into CQRS / Event sourcing but this seems pretty close to what an eventstore should be. Funny thing is: I really can't find that much about Kafka being used as an eventstore, so perhaps I must be missing

How to handle set based consistency validation in CQRS?

梦想的初衷 提交于 2019-11-26 13:08:46
问题 I have a fairly simple domain model involving a list of Facility aggregate roots. Given that I\'m using CQRS and an event-bus to handle events raised from the domain, how could you handle validation on sets? For example, say I have the following requirement: Facility \'s must have a unique name. Since I\'m using an eventually consistent database on the query side, the data in it is not guaranteed to be accurate at the time the event processesor processes the event. For example, a

Multiple Aggregates / Repositories in one Transaction

这一生的挚爱 提交于 2019-11-26 12:24:58
问题 I have a payment system as shown below. The payment can be made through multiple gift coupons. The gift coupons are issued along with a purchase. The customer can make use of this gift coupon for future purchase. When a Payment is made through gift coupon, the UsedForPaymentID column in GiftCoupon table need to be updated with that PaymentID (for the giftcoupon ID). The GiftCouponIDs are already available in the database. When a customer produces a gift coupon, it has GiftCouponID printed on

Communicating between two Bounded Contexts in DDD

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 10:31:49
问题 I have few different Bounded Contexts in the domain. The validation of a CRUD operation is built in each Bounded Context. For example, I can create an entity called GAME only if the person creating it is a Group Leader . I have two Bounded Contexts (BC) in this example. One is the Game BC and the other is the User BC . To solve the problem, in the Game BC , I have to make a domain service call like IsGroupLeader() to the User BC before proceeding on creating the Game. I don\'t think this type

Using Kafka as a (CQRS) Eventstore. Good idea?

扶醉桌前 提交于 2019-11-26 04:03:19
问题 Although I\'ve come across Kafka before, I just recently realized Kafka may perhaps be used as (the basis of) a CQRS, eventstore. One of the main points that Kafka supports: Event capturing / storing, all HA of course. Pub / sub architecture Ability to replay the eventlog which allows the ability for new subscribers to register with the system after the fact. Admittedly I\'m not 100% versed into CQRS / Event sourcing but this seems pretty close to what an eventstore should be. Funny thing is: