dri*_*zie 5 domain-driven-design domain-events
I am trying to further my understanding of DDD. More specifically, how to handle domain events via a message bus for asynchronous processing.
Lets say I have some architecture ->
_____________________
| |
| Client |
|_____________________|
|
__________|__________
| |
| Application Service |
|_____________________|
|
__________|__________
| |
| Domain |
|_____________________|
Run Code Online (Sandbox Code Playgroud)
When my domain raises some domain event, how do I get that event to a messaging service such as RabbitMQ?
My first thought is to inject a message bus service, IMessageBus, that knows how to send the events to RabbitMQ. The service would be used by domain event handlers to dispatch the event to the bus.
But then I thought, now my domain has to know how to handle its own events.
Can someone shed some light on the matter?
服务总线是基础设施的一部分,但应用程序服务了解它(作为抽象)。将总线注入到应用程序服务中是可以的,因为应用程序服务不包含域逻辑,而是充当业务用例的协调器和主机。
但后来我想,现在我的域必须知道如何处理自己的事件。
是的,但是总线仅传递消息,消息处理程序基本上是应用程序服务。
Rabbit 和其他都是实现细节,您的应用程序处理程序应该由服务总线调用(它应该抽象实际的消息传递过程)。
| 归档时间: |
|
| 查看次数: |
2217 次 |
| 最近记录: |