The Query<R> interface is the Kafka Streams contract implemented by objects that describe queries against state stores. It sits inside an Interactive Queries application that exposes loan-processing state through HTTP. section 13.2.1
A query-driven application typically combines these pieces:
- Create a typed query such as KeyQuery<String, LoanAppRollup> with the target key. section 13.2.1
- Place the query in a StateQueryRequest for a named store and selected partitions. section 13.2.1
- Extract QueryResult values and return them through a REST controller, querying another host when the target partition is remote. section 13.2.1
Loan-category lookup
A controller receives a loan category, creates a KeyQuery for that category, resolves its KeyQueryMetadata, and queries the owning partition for a LoanAppRollup. If another instance owns the partition, it forwards the request to that host. section 13.2.1
Listing 13.11 Creating a KeyQuery
KeyQuery<String, LoanAppRollup>
keyQuery = KeyQuery.withKey(loanType);
Inspect the compact Java construction of a typed KeyQuery. section 13.2.1
