79479140

Date: 2025-03-02 13:17:26
Score: 0.5
Natty:
Report link

DDD relies on a domain context. For your case, we have the following options, please consider one that you think is closer to the actual domain context:

  1. The Bot entity has limited knowledge about the Order flow, but the Exchange entity can somehow determine what Order it should process based on Order attributes: then Bot initiate Order creation, and Exchange handles OrderCreated domain event with all necessary routing attributes presented (closer to your current idea but requires additional routing layer on Exchange side).
  2. The Bot entity has complete knowledge about the Order and the target Exchange in advance: thus Bot initiates Order creation with Exchange link as Order Attribute, allowing Order entity to put Command to particular Exchange topic/queue instead of broadcasting the domain event (more coupling between Order and Exchange can be closer to your context). Please note the difference between Domain Event and Command (with Command pattern it is a consumer who owns message protocol and dictates producer how to trigger it)
  3. The Bot entity has partial knowledge but full ownership over the Order lifecycle, then Bot needs to subscribe to OrderCreated event to perform further processing steps (trigger Exchange command? make additional calc/enrichment?)
Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Ivan