为什么要分别表示命令和事件? [英] Why are commands and events separately represented?

查看:13
本文介绍了为什么要分别表示命令和事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

强调事件的架构中的命令和事件有什么区别?我能看到的唯一区别是命令通常是由系统外部的参与者获取/调用的,而事件似乎是由系统中的处理程序和其他代码获取的.但是,在我见过的许多示例应用程序中,它们具有不同(但功能相似)的接口.

What is the difference between commands and events in architectures that emphasize events? The only distinction I can see is that commands are usually sourced/invoked by actors outside the system, whereas events seem to be sourced by handlers and other code in a system. However, in many example applications I have seen, they have different (but functionally similar) interfaces.

推荐答案

命令可以被拒绝.

事件发生了.

这可能是最重要的原因.在事件驱动架构中,毫无疑问,引发的事件代表了已经发生的事情.

This is probably the most important reason. In an event-driven architecture, there can be no question that an event raised represents something that has happened.

现在,因为命令是我们想要发生的事情,而事件是已经发生的事情,所以我们在命名这些事情时应该使用不同的动词.这驱动了单独的表示.

Now, because Commands are something we want to happen, and Events are something that has happened, we should be using different verbs when we name these things. This drives separate representations.

我可以看到命令通常是由外部的参与者发起/调用系统,而事件似乎是由处理程序和其他代码来源一个系统

I can see is that commands are usually sourced/invoked by actors outside the system, whereas events seem to be sourced by handlers and other code in a system

这是它们分开表示的另一个原因.概念清晰.

This is another reason they are represented separately. Conceptual clarity.

命令和事件都是消息.但它们实际上是独立的概念,并且应该明确地对概念进行建模.

Commands and Events are both Messages. But they are in fact separate concepts, and concepts should be modeled explicitly.

这篇关于为什么要分别表示命令和事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆