Annotation Type KafkaStreamsStateStore
Interface for Kafka Stream state store.
This interface can be used to inject a state store specification into KStream building
process so that the desired store can be built by StreamBuilder and added to topology
for later use by processors. This is particularly useful when need to combine stream
DSL with low level processor APIs. In those cases, if a writable state store is desired
in processors, it needs to be created using this annotation. Here is the example.
@StreamListener("input")
@KafkaStreamsStateStore(name="mystate", type= KafkaStreamsStateStoreProperties.StoreType.WINDOW,
size=300000)
public void process(KStream<Object, Product> input) {
......
}
With that, you should be able to read/write this state store in your
processor/transformer code.
new Processor<Object, Product>() {
WindowStore<Object, String> state;
@Override
public void init(ProcessorContext processorContext) {
state = (WindowStore)processorContext.getStateStore("mystate");
......
}
}
- Author:
- Lei Chen
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether catching is enabled or not.Serde used for key.longLength in milli-second of Windowed store window.booleanWhether logging is enabled or not.Provides name of the state store.longRetention period for Windowed store windows.State store type.Serde used for value.
-
Element Details
-
name
String nameProvides name of the state store.- Returns:
- name of state store.
- Default:
- ""
-
type
State store type.- Returns:
KafkaStreamsStateStoreProperties.StoreTypeof state store.
- Default:
- KEYVALUE
-
keySerde
String keySerdeSerde used for key.- Returns:
- key serde of state store.
- Default:
- "org.apache.kafka.common.serialization.Serdes$StringSerde"
-
valueSerde
String valueSerdeSerde used for value.- Returns:
- value serde of state store.
- Default:
- "org.apache.kafka.common.serialization.Serdes$StringSerde"
-
lengthMs
long lengthMsLength in milli-second of Windowed store window.- Returns:
- length in milli-second of window(for windowed store).
- Default:
- 0L
-
retentionMs
long retentionMsRetention period for Windowed store windows.- Returns:
- the maximum period of time in milli-second to keep each window in this store(for windowed store).
- Default:
- 0L
-
cache
boolean cacheWhether catching is enabled or not.- Returns:
- whether caching should be enabled on the created store.
- Default:
- false
-
logging
boolean loggingWhether logging is enabled or not.- Returns:
- whether logging should be enabled on the created store.
- Default:
- true
-