From the course: Calling REST APIs with Java
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Asynchronous API calls - Java Tutorial
From the course: Calling REST APIs with Java
Asynchronous API calls
- [Instructor] In our previous examples, the requests that we sent to Azure Cognitive Services were sent synchronously. That means that the API call blocked the execution of our code. So here in line 69, once we sent the request over to the text analytics API, our code did not continue execution, it sat here and waited for that response to come back from the API. Now, we have other options in how we make this call. We can make the call asynchronous and when we make an asynchronous call, it's going to allow our code to continue executing while we wait on the response from the API and we can do this with the new Java 11 HTTP client. Let's take a look at this in action. So the first thing that we'll need to do is change from using the send method on the HTTP client to using the sendAsync method, and the mechanics of this method work a little bit differently. We're no longer going to return the HttpResponse, so I'm going…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Azure Cognitive Services5m 40s
-
(Locked)
Text Analytics API registration and security7m 34s
-
(Locked)
Java HTTP Client9m 29s
-
(Locked)
Calling Azure Cognitive Services APIs7m 9s
-
(Locked)
Asynchronous API calls6m 50s
-
(Locked)
Challenge: Cognitive Services API3m 25s
-
(Locked)
Solution: Cognitive Services API4m 54s
-
-
-
-