From the course: Java EE 8: Web Services

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Asynchronous REST service client

Asynchronous REST service client - Java EE Tutorial

From the course: Java EE 8: Web Services

Start my 1-month free trial

Asynchronous REST service client

- [Instructor] The default operation mode of the JAX-RS client is synchronous. The client opens the connection, sends a message and waits for the response, possibly indefinitely. And as the kids say, many use cases don't have time for that, I think that's how the meme goes. In this video I'll show you how to write an asynchronous JAX client. I'll open the connection and return control to you immediately, so you can do something else in the same thread while you wait for a response, if you want to wait. To demonstrate this, I've added code to our existing salute endpoint. The new code will select for the existence of a boolean inquiry parameter named make it wait. So here I've added at query param, looking for make it wait in the URL and it will inject that value into the boolean method parameter make it wait. If make it wait is set to true, I'm forcefully making the thread sleep here with line 57. It will force this thread…

Contents