SimpleCommandBus 和 AxonCommandServerBus 的区别

difference between SimpleCommandBus and AxonCommandServerBus

当我使用 axon 框架和阅读文档时,我看到我可以更改 queryBus、commandBus 和 eventBus,并且有三种类型:EmbeddedEventStore、SimpleCommandBus 和 AxonCommandServerBus 那么SimpleCommandBus、AxonCommandServerBus和EmbeddedEventStore有什么区别??

正如另一位用户在您的 问题下的回答,Axon 支持使用三种类型的消息:

  1. 命令 - 在域内执行某些操作的意图表达。
  2. 事件 - 域内发生相关事件的通知。
  3. 查询 - 信息或状态请求。

了解这一点后,无论何时您在寻找 CommandBusEventStore 实现之间的差异,都会转化为不同的消息类型。

Axon 提供 CommandBus 将命令消息从一端发送到另一端。这样做时,它会牢记命令的特定路由要求。该视角中的 EventStore 负责存储事件消息,并允许一个解决方案来检索聚合(事件源)和查询模型(事件流)的事件。

现在,实际描述它们是什么:

嵌入式事件存储

EventStore 接口的实现,使用 so-called EventStorageEngine 来保存事件。 EventStorageEngine 有一个 JPA、JDBC、Mongo 和 In-Memory 实现。

简而言之,这就是 Axon EventStore 的“配置您自己的事件存储”解决方案。如果您更喜欢使用配置较少的东西,我建议您使用 Axon Server.

SimpleCommandBus

SimpleCommandBus是一个单一的JVM,single-threaded实现了CommandBus接口。因此,它不允许在命令调度 and/or 处理中有任何并行性。也不支持向其他实例分发命令。

AxonServerCommandBus

AxonServerCommandBusCommandBus 接口的分布式 multi-threaded 实现,使用 Axon 服务器作为通信层。因此,它允许应用程序内的并行性。它还知道如何向其他应用程序实例发送命令和从其他应用程序实例检索命令。请注意,它期望 Axon 服务器 运行 并且您的 Axon Framework 应用程序可以访问它。


如果您对这三者之间更详细的区别感到好奇,我建议您阅读参考指南各自的部分:

  1. EmbeddedEventStore page
  2. SimpleCommandBus page
  3. AxonServerCommandBuspage