Abstract

Modern applications not only expose web service, they also consume other third-party web services. For example, your application may consume a Facebook or Twitter feed. Most modern web services are exposed using REST APIs that handle JSON payloads. A typical problem with calling web services is that they can block the caller and can result in blocking the server until a response is obtained or a timeout occurs. This is not a particularly good design because it can affect the throughput of the server and can result in missed SLAs. Play 2 has solved this problem by providing asynchronous, non-blocking APIs to invoke long-running tasks like an external web service. Play provides the play.libs.ws library to handle asynchronous web service calls. A call made by play.libs.ws returns CompletionStage . Later you can extract the response by using callback functions available in the CompletionStage interface. Essentially they are asynchronous callback methods. The caller makes a web service call and, once the response is available, the rest of the code runs. You will explore this in more detail later in this chapter.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call