How it works
A trusted product service submits a notification intent: a record of what should be sent to whom, separate from any delivery attempt. It carries an event ID, recipient, category, template version, parameters, and requested send time. The notification API authenticates that producer, checks schema and authorization, and assigns a stable notification ID. A public unauthenticated send endpoint would invite spam and costly provider calls.
Persist the intent before acknowledging acceptance. When a product change and its notification must move together, use a transactional outbox: a row describing the message, committed in the same database transaction as the change. A dispatcher then publishes outbox rows to durable work queues. Debezium, for example, can read such rows from the Postgres change log and publish them to Kafka.
Follow a refund. The refund and outbox rows commit together. The process dies before publishing. The dispatcher finds the unpublished row and publishes it, then dies before marking it sent, so after restarting it publishes again. The stable event ID lets the notification service discard the second copy. The cost is a table to purge and a dispatcher to run, which a disposable message such as “your friend is online” may not justify.
Queues buffer bursts and let workers scale independently. Split work by channel or priority so an SMS provider outage does not block email, and reserve capacity for urgent transactional events. A queue still needs retention, monitoring, and backpressure, a way to slow producers when workers fall behind; it is not itself proof of delivery.
An order commits, but the process crashes before it publishes the receipt event. How can the system avoid losing the receipt?
Commit an outbox record with the order, then have a separate publisher retry the record until the notification service durably accepts it. Use a stable event ID so publishing the same record again does not create a second logical intent.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Acknowledge only after the send intent has a durable recovery path.
- Separate channel and priority workloads so one slow provider does not stall every notification.