liveBook · Manning

Service query

As explained in Microservices Patterns, Second Edition

A service API operation that retrieves data needed by a query composed across multiple services.

A service query is an API operation that a provider service exposes for retrieving data needed by a query composed across services. An API composer calls these operations and combines their results into the response expected by the client. section 12.2.1

Design service queries and their composition by deciding:

  • Which services to call, what data to request, and the order of calls. section 12.3.2
  • How to merge results while balancing remote calls, response size, and latency. section 12.3.2
  • How to handle inconsistent results, such as a cancelled Order paired with a Ticket not yet cancelled. section 12.3.2

Order status

A composer may retrieve an Order from the Order Service and a Ticket from the Kitchen Service. If the Order is CANCELLED but the Ticket is not, the composition logic should resolve the mismatch before returning the response. section 12.3.2

Figure 12.5 The API composition pattern consists of an API composer and two or more provider services. The API composer implements a query by querying the providers via their APIs and combining the results.
ApiCompositionBasedQueryBigPicture

Shows an API composer querying provider services and combining their results. section 12.2.1

How Microservices Patterns, Second Edition covers it

How deep it goes
Details provider selection, call order, data requests, result merging, trade-offs, and inconsistent-result handling.
Examples
Uses a cancelled Order paired with an uncancelled Ticket to illustrate resolving inconsistent results.
What it assumes
Assumes provider services own relevant data and expose APIs defining service queries.
What you can do after
Evaluate/understand it by assessing provider capabilities, remote-call count, response size, latency, and result consistency.
How it connects
Connects service queries to API composition, API gateways, Backend-for-frontend services, REST, and gRPC.

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.