Quick revision
The short answer
Internal services send notification requests through an API or a Kafka topic, each with a template id, recipient, data and an idempotency key. The service looks up the user's preferences per channel and schedules delivery for later during quiet hours, then routes each message to per-channel queues and workers so a slow SMS provider never delays email. Provider adapters have timeouts, retries with backoff, circuit breakers and failover to a second provider; delivery status and provider callbacks such as delivered and bounced are stored for audit and suppression lists; and rate limits per user and per provider prevent spam and throttling.
What to remember
In this answer, we designed a notification service with an API and a Kafka topic taking requests with a template, recipient, data and an idempotency key. We applied preferences and quiet hours, isolated channels with their own queues and workers, protected sends with timeouts, retries, circuit breakers and provider failover, stored delivery status and callbacks to maintain suppression lists, added rate limits per user and per provider, and gave password resets their own priority lane.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Internal services send notification requests through an API or a Kafka topic, each with a template id, recipient, data and an idempotency key. The service looks up the user's preferences per channel and schedules delivery for later during quiet hours, then routes each message to per-channel queues and workers so a slow SMS provider never delays email. Provider adapters have timeouts, retries with backoff, circuit breakers and failover to a second provider; delivery status and provider callbacks such as delivered and bounced are stored for audit and suppression lists; and rate limits per user and per provider prevent spam and throttling.
Why this question is asked
Most companies start with every service sending its own emails and texts, and end up with inconsistent templates, ignored preferences, messages at 3 a.m. and outages whenever one provider fails. A central notification service fixes this, but it must be reliable enough that other teams trust it with password resets and order confirmations. Interviewers ask this design question because it covers API design, preferences and scheduling, queues and isolation, provider failure handling and feedback loops. In this answer, we will design the intake API, apply preferences and quiet hours, isolate channels, handle provider outages, track delivery status, add rate limits, and answer the follow-up on prioritising password resets over marketing.
1The Intake: API and Kafka Topic
Callers do not send finished emails; they send a request: a template id such as ORDER_SHIPPED, a recipient user id, the data to fill the template, optional preferred channels, a priority, and an idempotency key. Services that need a synchronous answer use a REST endpoint; services that already publish events use a Kafka topic. Both paths write the request to the service's own database with a unique constraint on the idempotency key, so a caller that retries does not cause a second message, and both return quickly once the request is stored.
2Preferences and Quiet Hours
For each request, the service asks a preference service, with a short cache, what this user allows: which channels are enabled for this category of message, whether they unsubscribed from marketing, their time zone and their quiet hours, for example 22:00 to 08:00. Messages for disabled channels are dropped with a recorded reason. If the current time falls in the user's quiet hours and the message is not critical, it is scheduled for the end of the quiet period instead of being sent now; a scheduler releases scheduled messages when their time comes. Templates are rendered at this stage in the user's language, producing one message per channel.
3Per-Channel Queues and Workers
Each channel has its own queue, for example its own Kafka topic, and its own pool of workers. The reason is isolation: if the SMS provider slows down to 5 seconds per message, SMS workers fall behind, but email and push keep flowing at full speed. A single shared queue would let the slowest channel block all others. Each pool can also be scaled and rate limited according to its provider's limits.
- IntakeREST API and Kafka topic, idempotency key
- Preferences and schedulingchannels, consent, quiet hours, templates
- Per-channel queuesemail, SMS, push, each with priority lanes
- Channel workersrate limits per user and per provider
- Provider adapterstimeouts, retries, circuit breakers, failover
- Delivery store and callbacksstatus, bounces, suppression lists
6 layers, from the top down. Step through them one at a time.
4Handling Provider Outages
Each provider sits behind an adapter with a short timeout, a few retries with exponential backoff for transient errors, and a Resilience4j circuit breaker. When a provider's breaker opens, the router fails over to a second provider for that channel, for example a second SMS gateway, so delivery continues. Failover needs care: if a call timed out, the first provider may have sent the message, so we pass our message id as the provider's idempotency key where supported, and accept that a timeout followed by failover can occasionally produce a duplicate. If both providers are down, messages wait in the queue and are retried later rather than being dropped.
- Take message from the SMS queue
- Within user and provider rate limits?YesContinueNoDelay and requeue
- Primary provider breaker closed?YesSend via primaryNoSend via secondary
- Accepted?YesStore status SENTNoRetry with backoff
- Callback arrives laterDELIVERED, BOUNCED or FAILED
5 steps in order. Play them, or step through them one at a time.
5Delivery Status and Suppression Lists
Every message gets a row with its status history: requested, scheduled, sent, and later delivered, bounced or failed. Providers report these through callbacks (webhooks), which we store idempotently by the provider's event id. This serves three needs. Support can answer "did the customer get the email?" in seconds. Audit and compliance can see what was sent and when. And hard bounces, invalid numbers and spam complaints go into suppression lists, so we stop sending to addresses that will never work, which protects our sender reputation with email providers and saves money on SMS.
6Rate Limits per User and per Provider
Two kinds of limit protect different things. A per-user limit, such as at most 3 marketing pushes per day and 10 notifications of any kind per hour, protects users from being spammed when several services fire at once; excess non-critical messages are dropped or merged into a digest. A per-provider limit respects the throughput each provider allows, for example 100 SMS per second on our contract; without it the provider throttles or rejects us. Token buckets in Redis, keyed by user id and by provider, implement both.
7Follow-up questions
How would you prioritise password reset messages over marketing campaigns?
Priority is part of the request and is set by the template, not the caller: password resets and one-time codes are CRITICAL, order updates TRANSACTIONAL, campaigns MARKETING. Each channel has separate queues or topics per priority with dedicated workers, so a campaign of 2 million emails sits in the marketing lane while a password reset goes through the critical lane in seconds. Critical messages also bypass quiet hours and user rate limits, and a share of each provider's rate limit is reserved for them, for example 20 percent, so a campaign cannot consume the whole provider quota.
How do you handle a template change while messages are scheduled?
Templates are versioned. A scheduled message stores the template version it was rendered with, or is rendered at send time with the latest published version, depending on what the business prefers; most choose render at send time for content fixes but keep the version for audit. Either way the delivery record stores what was actually sent.
8Conclusion
In this answer, we designed a notification service with an API and a Kafka topic taking requests with a template, recipient, data and an idempotency key. We applied preferences and quiet hours, isolated channels with their own queues and workers, protected sends with timeouts, retries, circuit breakers and provider failover, stored delivery status and callbacks to maintain suppression lists, added rate limits per user and per provider, and gave password resets their own priority lane.
Open with
I would build one service that other teams send notification requests to, either through a REST API or a Kafka topic. A request carries a template id, the recipient's user id, the data for the template, a priority and an idempotency key, and I store it with a unique constraint on that key so retries never send twice.
Then, if they want more
For each request, I look up the user's preferences for that category and channel, drop channels they disabled, and if it is within their quiet hours and not critical, schedule it for later. Then I render the template per channel and put each message on that channel's own queue with its own workers.
That isolation means a slow SMS provider only slows SMS, not email or push. Each provider sits behind an adapter with timeouts, retries with backoff and a circuit breaker, and when the breaker opens, the router fails over to a second provider for that channel, passing our message id as an idempotency key where possible.
I store the delivery status of every message and the providers' callbacks, delivered, bounced, complaint, which gives support and audit a full history and feeds suppression lists so we stop sending to bad addresses. I also rate limit per user, so people are not spammed when several services fire at once, and per provider, to stay within their throughput.
For priorities, password resets and codes go through a separate critical lane with reserved provider capacity, bypassing quiet hours, so a big marketing campaign can never delay them.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Design a notification service in Java and Spring Boot that sends email, SMS and push...": https://scrivio-interview-library.netlify.app/architecture/backend-system-design/2440da8ff1/