-1

I am trying to understand the DDD / Event-sourcing / CQRS etc.

Lets consider an e-comm application with below Microservices.

order-service
shipping-service
payment-service

Can you clarify these questions?

  • We can relate domain as a large application and bounded-context as an individual microservice, rt?
  • Will each bounded-context/Microservice maintain its own event-store? (Basically 1 domain can have multiple event-sotre?)
  • If it is going to be 1 event-store per domain, who takes the ownership of event-store?
RamPrakash
  • 2,218
  • 3
  • 25
  • 54

1 Answers1

0

Typically, a (logical) service will have exclusive authority to modify one or more streams.

Whether those streams are all together in a single durable store, or distributed across multiple stores, isn't particularly important so long as the service knows how to find the streams.

Similarly, it's not typically all that important that each service has its own store. Functionally, the important thing is that the different services not write to streams that are outside of their jurisdiction. So long as you can be confident that two services won't be trying to use the same stream identifier, it should be fine.

Note that both of these guides are the same that you would use if your services were writing rows into tables in an RDBMS. Tables don't have to be in the same database, so long as the service knows which database holds which tables. Similarly, two different services can share the same database so long as they don't write into each other's tables.

There are, of course, non functional reasons that you might want the storage for different services to be isolated. For instance, if one service wants to upgrade to a new version of storage, while another needs to lag behind, then it will be a lot more convenient if the services are not sharing a database. Similarly, certain kinds of audits will be more easily satisfied by isolating data storage.


If I go with CQRS for order-service, My question is - who is supposed to consume payment events. command side or read side of order-service?

If your ordering domain dynamics need information from payments, then the command side of ordering will need a copy of the information from payments.

The payments information is an unlocked copy of the data - the authoritative copy of that information in payments may be changing even as we are updating orders.

Assuming you don't want to tightly couple ordering to the domain dynamics of payments, the copy of the payments information used by ordering will normally be a report (aka a "read model") rather than a copy of the entire history.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91
  • Still little bit confused. If I go with CQRS for order-service, My question is - who is supposed to consume payment events. command side or read side of order-service? – RamPrakash Dec 19 '20 at 19:03
  • I am not sure if it is tight couplig. Order status depends on if payment is approved or not. So it is supposed to consume these events. So if the order-service write model is consuming these events. If the order-service has to take decisions based on the multiple events like payment and shipping approved - does it query its own event store to finally make the order completed status? The whole event-sourcing does not seem to make any sense. – RamPrakash Dec 19 '20 at 21:37