Skip to main content

One post tagged with "async"

View All Tags

· 6 min read

I’ve created a sample Spring Boot app that demonstrates useful scenario of asynchronous publish / subscribe model. It could be useful in many ways. Idea is that, for example, you have some API handling some web requests, and apart from functionality it provides, it also publishes some event, so that some other thread can react upon it, with main functionality still being processed with request handling thread. Or even shorter – request handling thread will do it’s job, and publishes some event (using Java annotation), and some other background thread will subscribe to event and process it. You can use it for scenario you register user with your API, and publish user registered event, and in background you can subscribe to it by sending out e-mail to end user.