Greg Young的CQRS实施中的服务目的
我决定通过 Greg Young 的实现
我不明白这里的服务是什么意思,因为它似乎与我们过去常见的三层模式完全不同。
客户端更改接收到的 DTO,并创建一个由其处理程序处理的命令,该处理程序调用域对象的方法。
然后创建事件并将其存储在事件存储中并发布以同步去规范化部分。
我在该链中找不到该服务。
我的同事告诉我,例如,如果我们在存储报告时不想将大数据存储为域的一部分,但当我们在域中需要它时,我们会发布一个从服务返回某些内容的事件。
但我无法在脑海中清晰地形成画面。
谁能解释一下这里应该做什么服务?
I decided to get acquainted with a concrete CQRS implementation on the example of Greg Young's implementation
What I do not understand is what is the meaning of services here because it seems to be completely other than we used to in common three-tier pattern.
The client changes the received DTO and it creates a command which is handled by its handler which calls a method of a domain object.
Then the event is created and stored in the event store and published to syncronise the denormolized part.
I cannot find the service in this chain.
My co-worker told me that for example that if we do not want to store large data as part of a domain when we store in reports but when we need it in our domain we publish an event which returns something from the service.
But I cannot clearly form the picture in my mind.
Can anyone explain what services are supposed to do here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在CQR中,基本上,命令处理程序是您在非CQRS方案中称为应用程序服务的内容。
In CQRS, basically the command handlers are what you'd call application services in non-CQRS scenarios.
根据您所讨论的上下文,“服务”可以代表不同的事物。阅读这篇文章,我相信他在 域服务,其中 构成 DDD 的构建块。
但是,在 CQRS 中,您通常拥有命令服务和查询服务,它们在 DDD 上下文中代表应用服务层。但正如我在阅读这篇文章时所说的那样,我认为他使用“服务”一词是指领域服务。
'Services' can represent different things depending on the context you are talking about. Reading the article I believe he is using the term 'service' in the context of Domain Services which form the building blocks of DDD.
However, in CQRS you typically have a command service and query service, which in DDD context represent the Application Service Layer. But as I say, reading the article, I think his use of the word 'service' is meant for domain services.
当您遇到诸如设置一致性验证之类的问题时。例如:设置验证帖子您可以需要一个服务来确保拒绝传入的重复命令,该命令的值只应保留一次。
在这种情况下,服务基本上是在具有主键约束的 Sql 表中进行插入。它只会发生一次,否则会抛出错误,整个过程失败,不会生成任何事件,查询端不会报告。
只是一个案例。
When you have problems like Set Consistency Validation. For example: Set Validation Post in SO you may need a Service that ensures that incoming duplicate commands of a value that should only be persisted once are rejected.
In this case, a service basically does an insert in a Sql table with a primary key constraint. It only happens once, otherwise, throws an error and the whole process fails and no events are generated, no reporting in the query side.
Just a case.
您的意思是服务是一个远程外观(Web 服务),它将调用应用程序层,因为域服务是不同的东西。
如果您正在设计n层应用程序以向其他层公开应用程序服务,则远程外观层(Web服务)将通过调用应用程序层来公开您的业务和命令,应用程序层如David所提到的:
对于阅读部分,在您的应用程序中您需要使用 FindOrders(x, y, z)、GetMostOrderedItems() 等方法设计一个查询服务,...
对于 Write 部分,您可以设计指挥服务之一类似的方式:
You mean about service a remote facade (Web service) which will call application layer, because domain service is a different thing.
The remote facade layer (web service) if you are designing n-tier application to expose application services to other tiers will expose your business and commands by calling the application layer, the application layer as mentioned by David:
For Read Part, in your application layer you need to design a Query Service with methods like
FindOrders(x, y, z)
,GetMostOrderedItems()
, ...For the Write part, you can design the command service in one of many ways like: