When I started learning Spring, I noticed something about many of the tutorials I found.
They often showed how to use a feature, but not always why it worked or when you should choose one approach over another.
I learn best by building things and documenting what I discover, so I started a project called spring-by-example.
The idea is simple: instead of building one large application, I’m creating a collection of small, focused examples where each example explores a specific Spring concept with clear explanations, tests, and documentation.
I’m happy to say that I’ve now completed Module 6 — Events. 🎉
The module covers:
- Publishing Events
- Listening for Events
- Custom Events
- Transactional Events
- Async Events
One thing I’ve really enjoyed about this module is seeing how Spring’s event system can help decouple different parts of an application.
For example, ApplicationEventPublisher allows one component to publish an event without needing to know which components will respond to it. @EventListener then provides a simple way for other components to react to those events.
I also explored custom events, which made it possible to model application-specific events such as an order being created.
Transactional events introduced another interesting concept: controlling when an event listener should run in relation to a transaction. With @TransactionalEventListener, event handling can be tied to transaction phases such as after a successful commit.
Finally, @Async showed how event listeners can be processed asynchronously, allowing the publisher to continue without waiting for the listener to finish.
The goal isn’t just to collect Spring annotations and APIs. I’m trying to understand how the Spring container works, how its features fit together, and why these features exist, one concept at a time.
The project is open source, and I’m continuing to build it as I learn:
🔗 GitHub: githu.b/mujuzimoses
There’s still a long way to go, but completing another module feels like a good milestone. 🚀
Next up: Spring AOP — exploring Aspect-Oriented Programming, proxies, aspects, advice, pointcuts, and how Spring applies cross-cutting concerns.
If you’ve worked with Spring before, what’s one part of Spring’s event system you think developers commonly misunderstand?
Top comments (0)