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

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

问题描述

强调事件的架构中的命令和事件之间的区别是什么?我可以看到的唯一区别是,命令通常由系统外的actor来源/调用,而事件似乎是由系统中的处理程序和其他代码来源的。但是,在我看过的很多示例应用程序中,它们有不同的(但功能类似的)接口。

解决方案

命令可以被拒绝。



活动已发生。



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

现在,因为命令是某事我们希望发生,而且事件是发生的事情,当我们命名这些事物时,我们应该使用不同的动词。这会驱动单独的表示。


我可以看到,命令通常是
来源/调用系统,而事件似乎是
源自处理程序和
a系统中的其他代码


这是另一个原因它们分别表示。概念清晰。



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


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.

解决方案

Commands can be rejected.

Events have happened.

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天全站免登陆