Etkileşimli Sorgular ve Durum Depoları
Kafka Streams'in yerel durum depolarını doğrudan sorgulamaya nasıl açtığını ve bir akış uygulamasını düşük gecikmeli somutlaştırılmış görünüme nasıl dönüştürdüğünü öğrenin.
Etkileşimli Sorgular ve Durum Depoları, CoddyKit'te ücretsiz bir Apache Kafka & Stream Processing Fundamentals dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Apache Kafka & Stream Processing Fundamentals öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Apache Kafka & Stream Processing Fundamentals kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
State Stores Recap
Stateful operations like aggregations and joins keep their data in state stores — local key-value stores backed by changelog topics for fault tolerance.
Normally results flow out to a topic, but they also live right inside your app.
What Are Interactive Queries?
Interactive Queries (IQ) let your application read those local state stores directly — no extra database, no re-consuming a topic.
Your streaming app effectively becomes a queryable materialized view.
Naming a Store
To query a store you must name it during materialization.
KTable<String, Long> counts = builder
.stream("clicks")
.groupByKey()
.count(Materialized.as("clicks-store"));Getting a Read Handle
After the app is running, fetch a read-only view of the store from the KafkaStreams instance.
ReadOnlyKeyValueStore<String, Long> store =
streams.store(StoreQueryParameters.fromNameAndType(
"clicks-store",
QueryableStoreTypes.keyValueStore()));Point Lookups & Range Scans
Once you have the store, query it like a map.
Long value = store.get("user-42");
KeyValueIterator<String, Long> all = store.all();
while (all.hasNext()) {
KeyValue<String, Long> kv = all.next();
}
all.close();The Distribution Problem
State is partitioned across app instances. A given key lives on only one instance.
If you query the wrong instance, you won't find the key — so the app needs to know who owns each key.
Discovering Key Owners
Kafka Streams can tell you which instance hosts a key, given the store name and key serializer.
KeyQueryMetadata meta = streams.queryMetadataForKey(
"clicks-store", "user-42", Serdes.String().serializer());
HostInfo host = meta.activeHost();Exposing application.server
Set application.server so each instance advertises its host and port. This metadata powers cross-instance routing.
props.put(StreamsConfig.APPLICATION_SERVER_CONFIG,
"node1.internal:8080");Building a Query REST Layer
A typical pattern: wrap the app in an HTTP server. On a request, find the owning host. If it's local, read the store; otherwise proxy to the remote instance.
Handling Rebalances
During rebalances, stores may be migrating and temporarily unavailable, raising InvalidStateStoreException.
- Retry with backoff.
- Check
KafkaStreams.State.RUNNINGbefore querying.
When to Use IQ
Interactive Queries shine when you want:
- Low-latency reads of aggregated state.
- To avoid a separate serving database.
- A self-contained, scalable materialized view.
For complex ad-hoc queries, a dedicated store may still be better.
Quick Check
Test your understanding of interactive queries.
Recap
You learned Interactive Queries.
- Name a store, then get a read-only handle from KafkaStreams.
- State is partitioned; use queryMetadataForKey to find owners.
- Set application.server and proxy cross-instance requests.
- Handle rebalance exceptions with retries.
Sıkça Sorulan Sorular
“Etkileşimli Sorgular ve Durum Depoları” dersi ücretsiz mi?
Evet — “Etkileşimli Sorgular ve Durum Depoları” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Apache Kafka & Stream Processing Fundamentals kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Apache Kafka & Stream Processing Fundamentals kursu toplamda 4 dersten oluşur.
“Etkileşimli Sorgular ve Durum Depoları” dersinde ne öğreneceğim?
Kafka Streams'in yerel durum depolarını doğrudan sorgulamaya nasıl açtığını ve bir akış uygulamasını düşük gecikmeli somutlaştırılmış görünüme nasıl dönüştürdüğünü öğrenin. Apache Kafka & Stream Processing Fundamentals ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Apache Kafka & Stream Processing Fundamentals öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Apache Kafka & Stream Processing Fundamentals, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Etkileşimli Sorgular ve Durum Depoları” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Apache Kafka & Stream Processing Fundamentals dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Apache Kafka & Stream Processing Fundamentals dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Kafka Streams'te Pencereleme İşlemleri
- Akışlarda Birleştirmeler ve Toplamalar
- Akış Analizi için KSQL'e Giriş
- Etkileşimli Sorgular ve Durum Depoları