Posts

Showing posts from February, 2016

Lesson learned with Ratpack and RxJava

We recently encountered an issue with integrating Ratpack with RxJava's Observables .  This post will detail what the error was, how it was broken and how it was fixed. The code  Essentially, our handler code was as follows (NOTE: see git project for this class  and also a test showing the behaviour of the broken code): @Override public void handle(Context context) throws Exception { Observable<String> contentFromDownstreamSystem = observableOnDifferentThreadService .getContent(); contentFromDownstreamSystem.subscribe(response -> { context.render( "Downstream system returned: " + response); } ); } The code above retrieves an Observable from a service.  As implied by the variable name, the Observable emits items on a different thread when it is subscribed to.  The Obsevable I have used to illustrate this issue is very simple and can be found here .  In our real world example, our Observable represented a Resu