How to model the requirement using domain driven design

家住魔仙堡 提交于 2019-12-25 03:13:44

问题


I have a requirement where i need to group the two events as one transaction by grouping them on certain criteria. Below is the some thoughts on the requirement.

Event ::

  1. We will receive events continuously to our systems.
  2. Each event will have some buffer time to group with other event.
  3. If buffer time elapses then we need to discard the event.
  4. We need to group the two events into one group depending on the two events information.
  5. If event information is not sufficient then we will send event info to other component which will response with corrected data.
  6. Whenever we grouping the events some times we want to hold the other event if related event went to data correcting component even though we are not 100% sure about the matching criteria. This step we want to perform because we want to match the events as many as possible.

I want to model this requirement using domain driven design any suggestions will be appreciated.


回答1:


Without knowing your business requirements, it's kind of hard to answer. But we can start with assumptions and definitions first:

I refer to an event in DDD as something that is important for your domain, has happened (in the past), is a undeniable fact and cannot be undone.

In my definition either aggregates or domain services are responsible for emitting events.

So your group of events looks like a concept that says that a group of related events is something important to my domain, too.

I guess you can go two ways to think about that concept:

  1. A group is a special view on your already happened events. Then a group is just a component which state is derived from a list of related events.
  2. A group is an aggregate that is a kind of a process that has a life cycle and based on state emits a single group event when the criteria for finishing a group is met

In the first case you can implement a group query that listens to published events and projects them to your group concept

In the second case you have an aggregate that reacts to business requests (you can call this a command) and manages some persistent state. When you request your aggregate to create a group and your aggregate is in the right state to do this, then your aggregate emits a group event.



来源:https://stackoverflow.com/questions/29367443/how-to-model-the-requirement-using-domain-driven-design

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!