Domain event

A Domain Event is triggered by a user action in a specific domain. It is an event generated by a behavior in the past, and this event is of interest to other parts of the system or related systems.

Why are domain events so important? Because in a distributed environment, very few business systems are monolithic. As a communication mechanism with the lowest coupling degree, the most robust, and the easiest to expand between distributed systems, messages are what we realize the interoperability of distributed systems Important means. Regarding domain events, we need to pay attention to two points, namely event naming and event content.

  1. Event naming: Events represent things that happened in the past, so it is recommended to use Domain Name + past tense of verbs + Event in naming, which can express business semantics more accurately.
  2. Event content: The event content is called payload in computer terminology and has the following two forms.
    Enrichment: It means to put as much data as possible in the payload of the event, so that the consumer can process the message without checking back, which is to process the message in a self-consistent manner.
    Query-Back: This method just puts the id attribute in the payload, and then the consumer gets more data in the form of callback. This form will increase the load on the system and may cause performance problems.

Guess you like

Origin blog.csdn.net/gou553323/article/details/112971236