【发布时间】:2020-11-22 13:46:18
【问题描述】:
在我当前使用 Java 的 EventSourcing 和 CQRS 的 Monolithic 应用程序中,我们有一个单独的写入和读取模型。
package com.command;
class Address{ //class created in Command Write model
String address;
}
package com.command;
import com.command.Address;
class CreateEmployeeCommand { //Command class belongs to Write Model
Address address; //this is correct
}
package com.events;
import com.command.Address;
class EmployeeCreatedEvent { //Event class belongs to Read Model
Address address; //this should not be correct IMO, instead seperate Address class should be created in event package.
}
在上述命令和事件类中,命令模型类“地址”已在它们之间共享。我认为上面是不正确的,而是应该为每个读写模型创建单独的地址类。通过使用上述方法,我们是否违反了关注点分离原则?以及如果我们在 Command 和 Event 类之间共享相同的 Command 模型,我们真正面临的其他实际问题是什么。请让我知道我的想法是对还是错..
【问题讨论】:
-
有人知道上面的答案吗?
标签: microservices cqrs event-sourcing event-driven event-driven-design