From the course: Java EE 8 Essential Training

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Asynchronous features

Asynchronous features

- [Instructor] JAX-RS 2.0 introduced the capability to make a resource method asynchronous, which allows developers to better utilize expensive resources like threads on a server. A typical resource method will hold a thread until a response is returned to the client. Using async, we can free up threads to perform processing while we wait for long running operations. Let's see this in action by adding an async resource method to our inventory items resource. To do that, we're going to create a copy of the find by catalog ID method on the class and once we do that, we'll need to change the name of the method. I'm just going to call it async find by catalog ID, and then async methods do not return anything, so we're going to change the type to void and then we'll go ahead and remove the body of the method. The next thing I'm going to do is remove the JAX-RS mapping annotations from the previous method. In order to indicate…

Contents