Scrivio Interview library

Application events

17 questions in 5 subtopics.

ApplicationEvent and publishing

ConceptFoundations5 min read
How do you publish an application event in Spring today, and do you still need to extend ApplicationEvent? Show a minimal publisher and the type the listener receives.
InternalsFoundations6 min read
When OrderService calls publisher.publishEvent(new OrderPlaced(id)) inside a method, what happens step by step until the listener returns, and what happens if the listener throws?
DesignIntermediate6 min read
A team uses application events to decouple an order module from email, analytics and loyalty modules in one Spring Boot service. When are in-process events a good fit, and when should they be replaced by a message broker or an outbox?
LeadershipPrincipal6 min read
Over a decade your organisation moved from synchronous calls to in-process events to brokers and event streaming. What lessons would you pass on about when an event-driven design pays off and when it creates long-term cost?

@EventListener

CodingFoundations6 min read
Read this listener:
@EventListener(condition = "#event.amount > 1000")
public AuditEntry onPayment(PaymentReceived event) {
return new AuditEntry(event.id());
}
What does the condition do, and what happens to the returned AuditEntry?
DebuggingFoundations5 min read
A @Component with an @EventListener method for ApplicationStartingEvent never logs anything, while its listener for ApplicationReadyEvent works. Why?
InternalsIntermediate6 min read
How does Spring turn @EventListener methods into listeners, and why can a listener on a prototype-scoped or lazily created bean behave unexpectedly?

@TransactionalEventListener

ConceptFoundations5 min read
What does @TransactionalEventListener do, what are its phases, and what happens if the event is published outside a transaction?
DebuggingIntermediate6 min read
An AFTER_COMMIT @TransactionalEventListener saves an AuditRecord with a Spring Data repository. No error is logged, but the row never appears in the database. Explain the cause and the fix.
DesignAdvanced6 min read
Several teams use @TransactionalEventListener(AFTER_COMMIT) to send Kafka messages after database commits, and incidents show occasional lost messages. What standard would you set for reliable post-commit publishing across services?
LeadershipPrincipal5 min read
Teams want to use in-process Spring events as the first step towards splitting a monolith into services. How would you judge this strategy over several years?

Asynchronous events

CodingFoundations5 min read
How do you make an @EventListener run asynchronously, and what changes for the publisher compared with a synchronous listener?
ScenarioIntermediate5 min read
A developer sets a TaskExecutor on the bean named applicationEventMulticaster so that all events are asynchronous. What breaks, and what would you recommend instead?
DesignAdvanced6 min read
Several services use @Async event listeners for side effects such as emails and search indexing, and work is lost on every deploy. What standard would you set for asynchronous side effects across services?

Event ordering

ConceptFoundations5 min read
Two @EventListener methods handle the same OrderPlaced event. How do you control which runs first, and what ordering do you get without any configuration?
LeadershipAdvanced6 min read
In a modular monolith, events between modules have grown to dozens of listeners with implicit ordering assumptions and hidden coupling. How would you bring this under control without banning events?
LeadershipPrincipal6 min read
Event ordering assumptions have caused subtle bugs in several of your systems, in-process and across brokers. What principles would you set for teams designing event flows for the long term?