JAX-RS 2.1 got a brand new reactive API to integrate with Java 8 CompletionStage but the server also has a nice integration to be reactive: @Suspended. For instance, the findAll method of QuoteResource could look like the following:
@Path("quote")@RequestScopedpublic class QuoteResource { @Inject private QuoteService quoteService; @Resource private ManagedExecutorService managedExecutorService; @GET public void findAll(@Suspended final AsyncResponse response, <1> @QueryParam("from") @DefaultValue("0") final int from, @QueryParam("to") @DefaultValue("10") final int to) { managedExecutorService.execute(() -> { <2> try { final long total = quoteService.countAll(); final List<JsonQuote> items = quoteService ...