Java Magazine, Jan/Feb 2018
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 17 reactive programming typically sends responses back to its originating requesters after doing its work When the application gets more requests than it can handle this thread will start to be a bottleneck and the application itself will not be able to be as responsive as it was before To have the application be responsive you need to make it scalable and resilient The reactive implementation might look more complicated at first glance but after closer examination you will see that its fairly straightforward because responsiveness is possible only with both scalability and resilience Resilience occurs when an application exhibits features such as auto recovery and self healing In most developers experience only a message driven architecture can enable a scalable resilient and responsive application Reactive programming has started to be baked into the bits of the Java 8 and Java EE 8 releases The Java language introduced concepts such as CompletionStage and its implementation CompletableFuture and Java EE started to employ these features in specifications such as the Reactive Client API of JAX RS JAX RS 21 Reactive Client API Lets look at how reactive programming can be used in Java EE 8 applications To follow along youll need familiarity with the basic Java EE APIs JAX RS 21 introduced a new way of creating a REST client with support for reactive programming The default invoker implementation provided by JAX RS is synchronous which means the client that is created will make a blocking call to the server endpoint An example for this implementation is shown in Listing 1 Listing 1 Response response ClientBuilder newClient target http localhost 8080 service url request
You must have JavaScript enabled to view digital editions.