Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Your team is extracting the notification feature from a Spring monolith into its own service. What are the first technical steps, and what typical mistakes should you avoid?

First we find everything the notification feature uses: its code, its tables and every caller that depends on it. Then, still inside the monolith, we put a clear interface in front of the feature and move callers onto it, before moving the implementation behind it into the new service. The new service must own its data rather than keep reading the monolith's tables, notifications should be triggered by events rather than many fine-grained synchronous HTTP calls, and we add monitoring and a way to route back to the old code before switching traffic.

Why this question is asked

Notifications are a popular first extraction from a monolith: the feature is fairly self-contained, failures are rarely catastrophic, and the team learns the mechanics of extraction on something low-risk. But first extractions also produce the classic mistakes, such as a 'service' that still reads the monolith's database or replaces one method call with ten HTTP calls. Interviewers ask this to see whether we know the safe order of steps. In this answer, we will map the feature, create an internal interface, move the implementation and its data, choose events over chatty calls, and switch traffic safely.

1Mapping the Feature, Its Data and Its Callers

Before moving anything, we need a full picture. On the code side, we find every class that belongs to notifications: templates, senders for email, SMS and push, preference handling, retry logic. On the data side, we list the tables it reads and writes, such as notification_template, notification_log and user_notification_preference, and, importantly, other tables it reads, like users for email addresses. On the caller side, we search for every place in the monolith that triggers a notification: order confirmation, password reset, shipping updates.

Tools help: IDE call hierarchies, a quick ArchUnit test listing dependencies on the notification package, and database query logs to see which tables the feature touches. The result often surprises the team, for example finding that a report joins notification_log with orders, which will break when the table moves.

2Creating an Interface Inside the Monolith First

The most important step happens before any new service exists. We define a clear interface for the feature inside the monolith and move every caller onto it. Callers stop using internal classes like EmailSender directly, and other modules stop reading notification tables.

Java
// Before: callers reach into notification internals
emailSender.send(user.getEmail(), templates.load("order-confirmed"), model);
// After: one narrow interface, owned by the notification module
public interface Notifications {
void orderConfirmed(long userId, String orderId);
void passwordReset(long userId, String resetToken);
}
// Callers in the monolith now only know this interface
notifications.orderConfirmed(order.userId(), order.id());

Notice that the interface speaks in business terms, 'order confirmed', not in technical ones like 'send email with template X'. That lets the notification side decide the channel, template and language, and it keeps the interface stable when the implementation moves. Once all callers use it, the extraction is a change behind one interface rather than in dozens of places.

3Moving the Implementation and the Data It Owns

Now we build the new notification service and move the implementation into it. The data the feature owns (templates, logs and preferences) moves with it into the service's own database. The common mistake is to leave the new service reading the monolith's tables directly 'for now'. That keeps the two tightly coupled through the schema: the monolith team can no longer change those tables without breaking the service, and we have gained a deployment unit without gaining independence.

For data the service needs but does not own, like a user's email address and language, there are better options. The event that triggers the notification can carry the needed fields, or the service can keep a small local copy updated by user-changed events, or, if necessary, it can call the user API. Each is better than a shared table, because the contract is explicit.

4Events Instead of Chatty HTTP Calls

Another typical mistake is turning the in-process call into synchronous HTTP: the order flow calls POST /notifications, waits for the answer, and fails the order if the notification service is down. Worse, a fine-grained design might need several calls (fetch the template, render it, send it), each one adding latency and a failure point.

Notifications are a natural fit for events, because the caller does not need an answer. The monolith publishes an OrderConfirmed event to a broker, and the notification service consumes it and decides what to send. If the service is down for ten minutes, the events wait in the broker and are processed when it recovers, and order placement is unaffected. To avoid losing events when the monolith's transaction commits but publishing fails, we use the transactional outbox pattern: write the event to an outbox table in the same transaction as the order, and publish it from there.

Step throughAn order confirmation after the extraction
MonolithOutbox tableBrokerNotification service
save order
insert OrderConfirmed, same transaction
relay publishes the event
deliver OrderConfirmed
load template and preferences from own DB
acknowledge

6 messages in order. Play them, or step through them one at a time.

The order is saved even if the notification service is down; the event waits in the broker.

5Monitoring and a Way Back Before Switching Traffic

Before any real notification goes through the new service, we add monitoring: events consumed per minute, notifications sent per channel, failures, consumer lag, and delivery success reported by the email or SMS provider. We compare these numbers with the old path's numbers so we can tell whether the new service behaves the same.

Then we switch gradually with a way back. Inside the monolith, the Notifications interface gets two implementations: the old in-process one, and one that publishes events. A feature flag decides which is used, for example per notification type, starting with a low-risk one like shipping updates, then order confirmations, and password resets last. If something goes wrong, flipping the flag routes back to the old code within seconds. Only when all types have run cleanly for a while do we delete the old implementation and its tables from the monolith.

Step throughSteps of the extraction
  1. Map code, tables and callers
  2. Introduce the Notifications interfacemove all callers onto it
  3. Build the service with its own datatemplates, logs, preferences
  4. Publish events via an outbox
  5. Switch one notification type with a flagmonitor and compare
  6. Healthy for all types?
    YesDelete old code and tablesNoFlip the flag back and fix

6 steps in order. Play them, or step through them one at a time.

6Follow-up questions

How do you avoid sending a notification twice?

Events can be delivered more than once, for example after a consumer restart. The service should be idempotent: store the event id with each sent notification and skip events it has already processed. That makes at-least-once delivery safe.

What about the report that joined notification_log with orders?

Once the table moves, that report must change: either the notification service exposes the data through an API or events into the reporting store, or the report moves to the data warehouse. Finding such dependencies early is exactly why we map the tables first.

Is it ever fine for the new service to read the monolith's database temporarily?

As a short, explicit transition step with a removal date, it can be acceptable, for example read-only access to user email addresses while the user events are being built. The danger is that 'temporary' becomes permanent, so it should be tracked like any other technical debt with an owner.

7Conclusion

In this answer, we saw the first technical steps for extracting notifications from a Spring monolith: map the code, tables and callers, introduce a business-level interface inside the monolith and move callers onto it, move the implementation with the data it owns, use events with an outbox rather than chatty synchronous calls, and add monitoring and a feature flag to route back before switching traffic type by type.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start by mapping the feature: all the notification code, the tables it reads and writes, including ones it does not own like users, and every caller in the monolith that triggers a notification.

Then, if they want more

Then, before creating any service, I would introduce a clear interface inside the monolith, in business terms like orderConfirmed or passwordReset, and move every caller onto it, so nobody touches the email sender or the notification tables directly anymore. Once that is done, the extraction happens behind one interface.

The new service gets its own database with the data it owns: templates, logs and preferences. A common mistake is letting the new service keep reading the monolith's tables, which keeps them coupled through the schema; for user data it needs, I would put the fields in the event or keep a small local copy.

The other common mistake is replacing the method call with synchronous HTTP calls, so orders fail when notifications are down. Notifications fit events well: the monolith writes an OrderConfirmed event to an outbox in the same transaction, it is published to the broker, and the service consumes it idempotently.

Finally, before switching, I add monitoring and compare numbers with the old path, and use a feature flag per notification type so we can route back to the old code instantly.

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 "Your team is extracting the notification feature from a Spring monolith into its own...": https://scrivio-interview-library.netlify.app/architecture/modernization/3268e80d2a/