【发布时间】:2014-09-19 06:25:46
【问题描述】:
我有一个与以数据为中心的流程中的 CQRS 相关的问题。让我更好地解释一下。 考虑我们有一个 SOAP/JSON/whatever 服务,它在集成过程中将一些数据传输到我们的系统。据说在 CQRS 中,每个状态的变化都必须通过命令(如果使用 Event Sourcing,则为事件)来实现。
在我们的集成过程中,我们有大量结构化数据,而不是一组命令/事件,我想知道如何实际处理这些数据。
// Some Façade service
class SomeService
{
$_someService;
public function __construct(SomeService $someService)
{
$this->_someService = $someService;
}
// Magic function to make it all good and
public function process($dto)
{
// if I get it correctly here I need somehow
// convert incoming dto (xml/json/array/etc)
// to a set of commands, i. e
$this->someService->doSomeStuff($dto->someStuffData);
// SomeStuffChangedEvent raised here
$this->someService->doSomeMoreStuff($dtom->someMoreStuffData);
// SomeMoreStuffChangedEvent raised here
}
}
我的问题是我的建议是否适合给定的情况,或者可能有一些更好的方法来做我需要的事情。提前谢谢你。
【问题讨论】:
-
看起来不错,尽管这取决于您的需求。您在针对您的应用程序服务进行这 2 次调用时是否遇到任何问题?
标签: domain-driven-design integration cqrs