Messagingmedium3-5 years
A topic named `SendInvoiceEmail` is consumed by both the `email` service and an `audit` service. What's wrong with this design, and how do you tell an event from a command in general?
An event is a past-tense fact — InvoiceIssued — that any number of consumers can react to, with the producer indifferent to who's listening. A command is a request to do something — SendInvoiceEmail — addressed to exactly one handler, with the sender expecting that specific work to happen. SendInvoiceEmail on a topic with two consumers is a command pretending to be an event: the name is an imperative instruction, but two services are subscribed to it, and if audit ever "helps" by acting on it too, the customer gets two emails. The tell is in the name — an imperative verb with more than one consumer is the specific shape of this bug.
Previous"Orders with customer names" used to be one JOIN. Once orders and customers are separate services with separate databases, what are the actual options for that query, and why isn't "let orders read the customers table directly" one of them?Next An orders service calls a slow, non-critical reporting service and a fast, critical payments service, both from the same shared thread pool. Why does a bulkhead around each matter, and which Resilience4j bulkhead type — semaphore or thread-pool — fits which?