Architecture model: Trading Outbox

Architecture model: Trading Outbox

While being referred

Application events (System events)

Context

Service command usually need to update the database and send messages / events. For example, the saga of the service involved needs to atomically update the database and send messages / events. Similarly, publishing domain event services must be updated atomically aggregation and release events. Database update message must be sent and the atoms to avoid data inconsistencies and errors. However, the use of database and messaging agents across distributed transaction to atomically update the database and publish messages / events is not feasible.

problem

How reliable / atomically update the database and publish messages / events?

focus point

  • You can not choose 2PC

in conclusion

A portion of the relational database using a service message / event as a local transaction is inserted into the outbox table (e.g. MESSAGE) in. Use the services NoSQL database to append messages / events to the record being updated (such as a document or project) properties. Message Relay separate process will be inserted into the database of events posted to the message broker.

Resulting Context

This model has the following benefits:

  • The senior field service release event
  • You can not choose 2PC

This model has the following disadvantages:

  • Since developers might forget to post messages after updating the database / events, it may be prone to error.

This model also has the following problems:

  • Message relay may be issued several messages. For example, it may be released after the news but it has done so in record prior to the crash. When you restart it will release message again. Thus, the user must be idempotent message may be a message ID by tracing it has already processed. Fortunately, due to the message users usually need to be idempotent (because the message broker can deliver the message several times), this is usually not a problem.

Related Patterns

    • Saga and Domain event model creates demand for this model.
    • Event traceability is another solution
    • Implementation of Message Relay has two modes:
      • Transaction Log trailing mode
      • Posted by polling mode

Guess you like

Origin www.cnblogs.com/paxlyf/p/11293718.html
Recommended