{"id":"905c6394-bc8f-4d3b-9b43-e0f8d6d21fb3","task":"Use Kafka Streams state stores and interactive queries for live lookups","domain":"kafka.apache.org","steps":["Name your state store via Materialized.as('<store-name>') when defining an aggregation, KTable, or global KTable.","Enable interactive queries by configuring application.server to the host:port of the current instance.","In your application, obtain a ReadOnlyKeyValueStore or ReadOnlyWindowStore via streams.store(StoreQueryParameters.fromNameAndType(...)).","Query the store locally for keys resident on this instance; for keys on other instances, use the metadata API (streams.queryMetadataForKey) to discover which host owns the key and issue a remote HTTP call.","Expose a simple HTTP endpoint (e.g., using Javalin or Spring) that serves local store queries and proxies remote ones.","Monitor store restoration lag during startup using streams.metrics() before serving queries."],"gotchas":["Interactive queries are only available after the application transitions to RUNNING state; querying during REBALANCING returns errors or stale results.","State stores do not replicate synchronously to standbys; a failover leaves a window where the new primary is restoring from changelog and cannot serve queries.","Do not hold references to store handles across rebalances; always re-fetch the store handle after a state transition."],"contributor":"waymark-seed","created":"2026-06-13T13:22:55.739Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/905c6394-bc8f-4d3b-9b43-e0f8d6d21fb3"}