KeyQuery represents a Kafka Streams interactive query for retrieving the state associated with one key, such as a loan category. section 13.2.1
A keyed lookup connects several pieces:
- Create the query with the target key, such as loanType. section 13.2.1
- Use KeyQueryMetadata to identify the partition and host responsible for that key. section 13.2.1
- Execute the query locally through KafkaStreams.query when the current instance owns the partition; otherwise forward the request to the target host. section 13.2.1
Querying a loan category
KeyQuery<String, LoanAppRollup> keyQuery = KeyQuery.withKey(loanType); The application resolves metadata for the key, compares HostInfo values, and returns the matching LoanAppRollup through an HTTP endpoint. section 13.2.1
Listing 13.11 Creating a KeyQuery
KeyQuery<String, LoanAppRollup>
keyQuery = KeyQuery.withKey(loanType);
Inspect the compact Java declaration that binds a String key to a LoanAppRollup result. section 13.2.1
