-
Notifications
You must be signed in to change notification settings - Fork 86
Description
In the Java kafka-streams
library, interactive queries let developers access local state stores directly. This enables efficient, local key-value lookups (via ReadOnlyKeyValueStore.get(key)
), perfect for low-latency dashboards, API endpoints, and RPC layers without needing to produce events or use streaming joins.
💡 Why this matters
These interactive queries allow state to be accumulated incrementally and queried on-demand, enabling distributed key-value stores across application instances, each owning a shard. Lookups differ from streaming joins because they're external, random-access reads—not part of the streaming topology.
In contrast, while Quix Streams supports stateful processing via RocksDB-backed state stores, there’s no public API to query those stores outside of the .apply()
or .update()
callbacks. That means you can't synchronously fetch state during a REST request—the REST handler can't access State.get(...)
outside streaming callbacks.
❌ An alternative approach that does not work
When you try to simulate a lookup by sending a message to a Kafka topic and then waiting for the streaming pipeline to output the response, you end up building a request-response loop:
- A REST handler publishes a lookup request message.
- A streaming pipeline processes that message.
- The method
.apply(..., stateful=True)
generates a lookup-output record. - The REST handler consumes the response.
This paradigm combines async streaming with synchronous REST, introducing latency, complexity, and timing issues. It's not equivalent to a Kafka Streams interactive query, where you can call store.get(key)
directly within service code. If Quix Streams exposed an API like Kafka Streams' store(...)
, you could write:
store = app.store("my-kv-store")
value = store.get(key)
Have you ever considered to add a similar feature to Quix Stream?