Create a non-blocking REST Api using Spring @Async and Polling
I love the Spring REST Api and how easy it is to create one; these days you barely need to write any code. You don’t really need understand the complexities of Spring as there are plenty of examples to get you started, or even finished for that matter. Failing that, there is always ChatGPT to help with any unique requirements, give a more detailed explanation in minutes rather than hours of wading through documentation and Stackoverflow.
When I was a junior engineer I jumped on all the new technologies, one of which was Reactive Streams. New and exciting full of promise, the solution to all our synchronous REST calls, with non-blocking event-loops, fluxes and monos… not to mention publishers, subscribers and back-pressure. Then the paradigm shift to processing flux and monos in streams, when you just want your good old pojo back. Don’t get me started on the debugging :(.
Although I did write some nice fast code that I was proud of, it was very complicated and pretty much no one else could pick it up easily (that includes me after a month of not working on it). The reactive programming never did capture the simplicity, beauty and readability of the traditional Spring REST Api.
So for those who want a simple Spring REST Api which is non-blocking, so you are not waiting around for a…