liveBook · Manning

Query

As explained in Microservices Patterns, Second Edition

A system operation that retrieves application data without mutating it.

A query is a system operation that retrieves application data without changing it. Unlike commands, queries do not mutate data; they commonly supply information for user-facing views. section 3.1.1 section 12.1.1

Read-only does not mean consistency is irrelevant: a query spanning multiple reads may otherwise combine old and new values. In a monolith, local data can be retrieved with SQL joins inside a transaction. Across services, data is private to each service and must be accessed through its API. section 12.1.3 section 12.1.4

Figure 12.1 To populate the Order Details view, the FTGO mobile application must somehow get information that’s scattered across multiple subdomains in the FTGO application.
FindOrderQueryOperation OrderStatusView

The Order Details view illustrates why one query may need to gather information from several subdomains. section 12.1.1

API composition is one way to implement a distributed query: a composer calls provider services through their APIs and combines their results. It fits queries that providers can answer efficiently; unsupported searches or large in-memory joins can make it unsuitable. section 12.2.1

findOrder()

A composer handles GET /orders/{orderId}, queries four provider services by orderId, and joins their responses for the client. section 12.2.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines read-only operations, explains snapshot isolation, and outlines monolithic and distributed query implementations.
Examples
Uses an Order Details view and findOrder() to illustrate queries across subdomains and services.
What you can do after
Evaluate whether a query suits local joins or API composition across services.
How it connects
Connects queries to commands, API composition, provider services, and service APIs.

Also explained in

Compare how 2 books explain query →

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.