Asynchronous processing

There are common scenarios in enterprise applications that are usually synchronous and blocking, for example, database or remote server calls. In those cases, the call at these methods takes some time to return, usually with a client thread that is blocked waiting for the answer. Let's consider a simple example—a Java EE servlet that queries a database, using a service, and prints the list of the records, in our case a list of authors (yes, I know, I'm a little bit egocentric):

@WebServlet(urlPatterns = "/authors")public class AuthorServlet extends HttpServlet {    ...    @Override    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws           ServletException, IOException { final List<Author> authors = authorService.getAuthors(); ...

Get Hands-On Cloud-Native Microservices with Jakarta EE now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.