The earlier overview post showed the notification flow as a diagram. This series opens each box and looks at how it works in the real service. We start at the front door: how an event turns into a notification.
The core idea
Other services never send notifications themselves. When something happens that a user should hear about (a KYC status change, a transaction update, an account lock, a password change, an OTP request), the service that owns it publishes an event to Kafka. The notification service consumes those events and decides what to send and where.
That keeps business logic and delivery apart. The service that moves money has no idea what a push token or an SMS provider is. The notification service has no idea how a transaction works. Neither has to.
What an event carries
Every event type has its own Kafka topic and its own message shape, but they share some fields:
- An
eventId, unique per event. Idempotency depends on it (Part 4). - A
userId, the person the notification is for. - The message itself: a title and a body.
- Delivery details: FCM device tokens for push, an email address for email.
- Sometimes a priority.
The delivery details travel inside the event. At send time the notification service doesn't call anyone to look up a token or an address.
One listener per event type
Each topic gets its own listener class and its own container factory. A listener is small. It receives one event, validates it and hands it to whichever channels that event needs. For example:
- A KYC workflow event stores an in-app notification and sends a push.
- An OTP request sends an SMS or an email.
- An error alert from another service goes to Slack.
- A forgot-password event sends a transactional email.
Since each listener stands alone, you can change, pause or fix one event type without touching the rest.
How parallelism works
All the listeners share one Kafka consumer group. Kafka gives each topic partition to exactly one consumer in the group at a time, which has two consequences.
Order holds within a partition, because events on the same partition are handled one after another. And scaling means adding replicas: more instances spread the partitions over more consumers. The listener factories don't raise the thread count per listener, so throughput grows with partitions and replicas, not with threads.
Messages that can't be parsed
The consumers use an error-handling deserializer. If a message is malformed, it becomes an error the framework deals with. It doesn't crash the listener loop, so one bad message can't block everything queued behind it on that partition.
What intake doesn't do
There's no rate limiting here. Overload protection comes later in the pipeline, through capped concurrency and circuit breakers (Part 7). The intake layer also doesn't check user preferences before sending. Today the event decides which channels get used.
Where this leaves us
Intake is deliberately plain: a topic and a listener per event type, one consumer group for scale, and every delivery detail inside the event. Next up is what happens when the same event shows up twice, and how the in-app timeline is stored.
Top comments (0)