0

I'm creating a system using CQRS and Event Sourcing pattern (I hope so). I have to make a business decision dependent on statistics data stored by one read model and user setting data stored by different read model (both created by events in the past). What is a good place to put business logic rules that outcome of which depends on that data?

  • Is it a command (can I fetch data stored in read models in command)?

  • Other abstraction layer, like saga?

Dawid Dominiak
  • 497
  • 2
  • 7
  • 11

1 Answers1

2

Your business model should work only with the business model. You need a 'read' model but specific for the business side. This is not the same query/read model used for UI, reporting. Business logic rules are always part of the business layer, the command part. They can be part of a business object or a service (which usually is a command handler).

A command is just a dto containing input data. It shouldn't contain any business rules.

Saga is the name of a long running (asynchronus) process, it isn't an abstraction layer, or any layer.

MikeSW
  • 16,140
  • 3
  • 39
  • 53
  • So to sum up, I can use a separate read model (which should better match to my business rules). Then I can fetch that read model data from command handler and based on that I can make a decision. Thank you for your clarification! – Dawid Dominiak Jul 31 '15 at 06:50