liveBook · Manning

Asynchronous programming

As explained in Microservices Patterns, Second Edition

An asynchronous implementation performs an operation's work independently of the caller after the invocation returns.

An asynchronous implementation lets an operation continue after its caller receives a response. For a synchronous HTTP request, this can decouple the response from work performed through messages. section 8.3.9

Choose when the HTTP controller responds:

  • After processing completes: return the final outcome, but remain runtime-coupled to collaborating services; latency rises and availability falls if they are unavailable. section 8.3.9
  • After sending the first message: validate using local data, update business entities, send messages, then respond. This avoids waiting for other services. section 8.3.9

Order creation

An Order Service can create an order without calling other services, respond, then validate the order asynchronously through messages exchanged with the Consumer and Restaurant Services. section 8.3.9

Figure 8.20 The Order Service creates an order without invoking any other service, which eliminates runtime coupling. The service then asynchronously validates the newly created Order by exchanging messages with other services, including the Consumer Service and the Restaurant Service.
self contained order taking

Trace how local order creation separates the HTTP response from subsequent validation by other services. section 8.3.9

How Microservices Patterns, Second Edition covers it

How deep it goes
Compares two response timings and outlines the early-response steps and trade-offs.
Examples
Uses order creation and validation involving Consumer and Restaurant Services.
What you can do after
Evaluate response timing by weighing final outcomes against latency, availability, and runtime coupling.
How it connects
Connects asynchronous messaging with REST endpoints, microservices, and the Saga pattern.

Also explained in

Compare how 37 books explain asynchronous programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.