首页 文章

Lagom和inter-PersistentEntity引用

提问于
浏览
0

在Lagom中,聚合根[DDD]每个都表示为PersistentEntity . 是否有可能一个PersistentEntity解析并保持对不同PersistentEntity的引用?我找不到任何说明这种情况的Lagom示例 .

1 回答

  • 2

    是的,您可以在实体的状态(事件和快照)中保存另一个PersistentEntity的标识符(实体ID) . 您可以将PersistentEntityRegistry注入PersistentEntity类,就像进入服务impl一样 . 当您想要向另一个实体发送命令时,您只需按类型和实体ID从注册表中获取PersistentEntityRef .

    如果你're doing is not 959022 but you send a command to another entity (from your command handler I'假设)并且想要在回复到来时做某事,请注意如何处理该回复,因为交互是异步的 . 您可以在以下主题中阅读有关此案例的更多信息:Lagom: Asynchronous Operations in Command Handlers

相关问题