Showing posts from February, 2017

Using a ReturnValueHandler to adapt RxJava Observables to Deferredresult in a SpringBoot micro service

If you look at my previous blog posts related to RxJava and Spring Boot microservices you may notice that all the subscriptions to the RxJava Observables are made in each and every controller method and controller method is responsible for the transformation between RxJava Observables and Spring aware DeferredResults. This is obvious one to one mapping that you can do between RxJava and Spring. In fact you can go further and generalize this behaviour. This will eliminate lots of boilerplate code in your application and make your code much more simple and readable. Also this brings a good software engineering practice called generalization and reuse into our code. Take a look at the following controller code before adding the return value handler.
We can use a simple ReturnValueHandler that calls an adapter[Gamma95] that will adapt Observables to DeferredResults. By registering this value handler with Spring, all the methods that return an Observable will be reworked into returning a …