Publish, match, deliver
Billing only publishes. The events API writes the event and replies; a matcher finds, in a cache, the endpoints that want that type and writes one delivery for each. Stateless senders send each one on its own and record every attempt.
- Billing calls
POST /v1/with its key and the event.events - The API writes the event to the events log and replies
202with the event id. - The matcher reads it and finds, in the subscriptions cache, the endpoints that want
invoice.paid. - It writes one delivery each for A and B; senders post each and save every attempt.
Diagram as text
Components: Billing service (Service); Events API (API gateway); Events log (Queue); Matcher (Service); Subscriptions cache (Cache); Endpoint A (External API); Senders (Worker); Deliveries queue (Queue); Endpoint B (External API). Connections: Billing service → Events API (publish); Events API → Events log (write, then 202); Events log → Matcher; Matcher → Subscriptions cache (lookup); Matcher → Deliveries queue (one for A, one for B); Deliveries queue → Senders (each on its own); Senders → Endpoint A (POST); Senders → Endpoint B (POST).
Read:Learn: High-level architectureLearn: Producer-consumer / work queue
Check yourself
Why not let billing post to each endpoint before it replies to its own caller?
Show answerHide answer
Every paid invoice would wait for the slowest customer’s server, and a customer’s outage would become a billing outage.