Scrivio Interview library

Event-driven patterns

19 questions in 6 subtopics.

Transactional outbox

ConceptFoundations6 min read
An order service saves an order with JPA and then calls kafkaTemplate.send("order-created", ...) inside the same @Transactional method. What can go wrong, and how does the transactional outbox pattern solve it?
DesignIntermediate7 min read
Design an outbox relay for a high-volume service. Compare polling the outbox table with change data capture, and explain how you keep per-aggregate ordering and stop the table growing forever.
LeadershipAdvanced6 min read
Half of your teams publish events directly after database commits and the other half use various outbox implementations. Incidents show lost and phantom events. What platform approach would you take?
LeadershipPrincipal6 min read
Your company is moving from synchronous REST between services to an event-driven architecture. As the senior technical leader, how do you decide how far to go, and what organisational changes are needed?

Saga

ScenarioIntermediate8 min read
In a choreographed saga, an order sometimes stays in PENDING forever. Logs show the payment service failed after reserving funds and the event it should have emitted never arrived. How would you find and prevent stuck sagas?
DesignIntermediate7 min read
Design a saga for placing an order that reserves stock, charges payment and books shipping, each in a different service. Compare choreography and orchestration, and describe the compensations.
LeadershipAdvanced6 min read
Several teams are building their own saga frameworks. Would you adopt a workflow engine (for example Temporal or Camunda) as a company standard? How would you decide?

CQRS

ConceptIntermediate6 min read
What is CQRS, and when is it worth separating the read model from the write model in a Spring service? What problems does it introduce?
ScenarioAdvanced6 min read
A product page in your CQRS system is built from a read model updated by events. After a change, users see their own edits disappear for a few seconds and file bugs. How would you handle this across the UI and services?
LeadershipPrincipal6 min read
Many teams build their own read models, search indexes and reporting copies from domain events, and the number of copies of core data keeps growing. How would you guide the organisation on when to build read models and how to keep the total cost under control?

Event sourcing

ConceptIntermediate6 min read
What does event sourcing mean, and how do snapshots, projections and upcasting work in an event-sourced service?
ScenarioAdvanced7 min read
A regulator requires you to delete a customer's personal data, but your account service is event-sourced and events are immutable. How do you comply?
LeadershipPrincipal6 min read
A team proposes event sourcing as the default architecture for all new services in your company. How would you respond?

Idempotent consumers

CodingFoundations7 min read
Write the core of an idempotent Kafka consumer in Spring that applies a PaymentReceived event to an account balance exactly once, even when the same event is delivered twice.
DesignIntermediate6 min read
Compare ways to make consumers idempotent: deduplication tables, natural idempotency (upserts, set-based updates), and version checks. Give an example where each fits.
LeadershipAdvanced6 min read
How would you make idempotent consumers a reliable practice across 40 teams rather than something each team remembers or forgets?

Event schema evolution

ConceptFoundations6 min read
What do backward and forward compatibility mean for events, and which changes to a JSON event are usually safe?
ScenarioIntermediate6 min read
You need to change a published OrderPlaced event: split "customerName" into "firstName" and "lastName" and change "amount" from a number to an object with value and currency. Eight services consume the event. How do you roll this out?
LeadershipPrincipal6 min read
Event contracts in your company have become as important as public APIs, but they change without notice and break consumers. What governance model would you put in place?