Skip to Content
Building RESTful Web Services with Java EE 8
book

Building RESTful Web Services with Java EE 8

by Mario-Leander Reimer
July 2018
Intermediate to advanced
116 pages
2h 41m
English
Packt Publishing
Content preview from Building RESTful Web Services with Java EE 8

Using ManagedExecutorService and server-side callbacks

In this section, we're going to take a look at using a ManagedExecutorService instance for asynchronous request processing. I'm going to show you how to use CompletableFuture to run and resume asynchronous requests. We will talk about using a TimeoutHandler instance for fine-grained timer control, and we'll be using CompletionCallback and ConnectionCallback instances for even further control of the request processing.

Let's get started and switch to code. As usual, we prepare a template project to get started. The first thing we want to do is use a ManagedExecutorService instance. Thus, we will inject this instance into our REST resource:

@Resourceprivate ManagedEcecutorService executorService; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

RESTful Java Web Services - Third Edition

RESTful Java Web Services - Third Edition

Balachandar Bogunuva Mohanram

Publisher Resources

ISBN: 9781789532883Supplemental Content