简体   繁体   English

Axon框架-对每个聚合根使用单独的Mongo域事件集合

[英]Axon framework - using separate Mongo collection of domain events for each aggregate root

We worry about performance of using single Mongo collection (domainevents) for domain events. 我们担心将单个Mongo集合(domainevents)用于域事件的性能。

Is it good idea to split domainevents collection to separate collections for each aggregate root? 将domainevents集合拆分为每个聚合根的单独集合是个好主意吗?

We have query model, that is generated based on events from multiple aggregate roots. 我们有查询模型,它是基于来自多个聚合根的事件生成的。 If we split domainevents to multiple collections, will Axon still preserve the order of events across aggregate roots? 如果将domainevents拆分为多个集合,Axon是否仍会保留聚合根中事件的顺序?

And is it generally good idea to do this? 这样做通常是个好主意吗?

There are a few questions here, that require different knowledge to answer. 这里有一些问题,需要不同的知识来回答。 I am not a MongoDB expert, but do know my way around Axon, being the founder. 我不是MongoDB专家,但确实知道我是Axon的创始人。

The MongoEventStore in Axon doesn't natively support multiple collections for the domain events. Axon中的MongoEventStore本身不支持域事件的多个集合。 So the answer to your order preservation query is: it won't work, unless you build support for it yourself. 因此,订单保留查询的答案是:除非您自己为其建立支持,否则它将不起作用。 And then the order is guaranteed depending on how you built it. 然后根据您的构建方式保证订单。

You can also consider sharding the Mongo Collection. 您也可以考虑分片Mongo Collection。 Using the aggregate identifier as shard key will allow you to guarantee that queries for an aggregate stream hit a single shard. 使用聚合标识符作为分片键将使您能够保证对聚合流的查询命中单个分片。 According to the documentation, it is recommended to avoid queries that do not include this shard key. 根据文档,建议避免查询不包含此分片键的查询。

The best approach to dealing with this performance issue, is to do a performance test. 解决此性能问题的最佳方法是进行性能测试。 See how latency and throughput are affected as the size of the collection grows. 了解随着集合大小的增长,延迟和吞吐量如何受到影响。 Adding the right indexes may help. 添加正确的索引可能会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从轴突框架中的聚合成员访问聚合根状态 - How can I access aggregate root state from aggregate member in axon framework 使用Spring Data Common发布域事件时如何处理没有存储库的聚合根 - How to deal with the aggregate root without repository, when using Spring Data Common to publish domain events Axon Framework从domain_event_entry表读取所有事件,而不是在其中序列化有效负载 - Axon Framework read all events from domain_event_entry table, and not to serialize payload in it 如何在轴心框架的Java中不使用Spring的情况下配置处理命令和调度事件的聚合类? - How to configure aggregate class which handles command and dispatch event without using spring in java with axon framework? Axon 事件存储处理 - 读取聚合的所有事件 - Axon Event Store Handling - Read All events for an aggregate Axon 框架:聚合自动装配 Bean 在测试中抛出 NullPointerException - Axon Framework: Aggregate Autowired Bean throws NullPointerException in Test 在春季启动时为Axon Framework设置Mongo Extension - Setting up Mongo Extension for Axon Framework on spring boot Axon FrameWork:如何在domain_event_entry表中回滚 - Axon FrameWork: How to rollback in the domain_event_entry table Axon 框架:在两个或三个微服务之间具有补偿事件的 Saga 项目 - Axon Framework: Saga project with compensation events between two or three microservices Axon 框架:如何在单元测试中检索状态存储的聚合 id 的 id - Axon framework: How to retrieve id of a state-stored aggregate id in a unit test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM