From the course: Java EE 7: Web Services

Unlock the full course today

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

Use advanced features

Use advanced features - Java EE Tutorial

From the course: Java EE 7: Web Services

Start my 1-month free trial

Use advanced features

- [Instructor] Up to this point, all of the examples we've seen illustrate synchronous processing. But what if there's a need to process a request asynchronously, meaning the code doesn't sit and wait for a response, and processes the response when it comes back using an invocation callback? The async method allows the client to be invoked asynchronously. The response is a future instance that can be used to monitor the status, cancel the call, or retrieve results. I've also registered an InvocationCallback to receive the events from the asynchronous call. Let's see this in action. I've opened the project in IntelliJ and navigated to the REST client module and opened the RestClient.java file. The server is running and the API code has been deployed. So let's look at this. On line 16, the future instance is returned and notice, starting on line 22, I've registered the invocation callback. Notice there are two methods, completed, and failed. The completed method is called on successful…

Contents