public class KStreamBuilder extends TopologyBuilder
KStreamBuilder
is a subclass of TopologyBuilder
that provides the Kafka Streams DSL
for users to specify computational logic and translates the given logic to a org.apache.kafka.streams.processor.internals.ProcessorTopology
.TopologyBuilder.TopicsInfo
Constructor and Description |
---|
KStreamBuilder()
Create a new
KStreamBuilder instance. |
Modifier and Type | Method and Description |
---|---|
<K,V> KStream<K,V> |
merge(KStream<K,V>... streams)
Create a new instance of
KStream by merging the given streams. |
String |
newName(String prefix)
Create a unique processor name used for translation into the processor topology.
|
<K,V> KStream<K,V> |
stream(Serde<K> keySerde,
Serde<V> valSerde,
String... topics)
Create a
KStream instance from the specified topics. |
<K,V> KStream<K,V> |
stream(String... topics)
Create a
KStream instance from the specified topics. |
<K,V> KTable<K,V> |
table(Serde<K> keySerde,
Serde<V> valSerde,
String topic)
Create a
KTable instance for the specified topic. |
<K,V> KTable<K,V> |
table(String topic)
Create a
KTable instance for the specified topic. |
addInternalTopic, addProcessor, addSink, addSink, addSink, addSink, addSource, addSource, addStateStore, addStateStore, build, connectProcessorAndStateStores, connectProcessors, copartitionGroups, copartitionSources, nodeGroups, sourceTopics, topicGroups
public KStreamBuilder()
KStreamBuilder
instance.public <K,V> KStream<K,V> stream(String... topics)
KStream
instance from the specified topics.
The default deserializers specified in the config are used.
If multiple topics are specified there are nor ordering guaranteed for records from different topics.
topics
- the topic names; must contain at least one topic nameKStream
for the specified topicspublic <K,V> KStream<K,V> stream(Serde<K> keySerde, Serde<V> valSerde, String... topics)
KStream
instance from the specified topics.
If multiple topics are specified there are nor ordering guaranteed for records from different topics.
keySerde
- key serde used to read this source KStream
,
if not specified the default serde defined in the configs will be usedvalSerde
- value serde used to read this source KStream
,
if not specified the default serde defined in the configs will be usedtopics
- the topic names; must contain at least one topic nameKStream
for the specified topicspublic <K,V> KTable<K,V> table(String topic)
KTable
instance for the specified topic.
Record keys of the topic should never by null, otherwise an exception will be thrown at runtime.
The default deserializers specified in the config are used.topic
- the topic name; cannot be nullKTable
for the specified topicspublic <K,V> KTable<K,V> table(Serde<K> keySerde, Serde<V> valSerde, String topic)
KTable
instance for the specified topic.
Record keys of the topic should never by null, otherwise an exception will be thrown at runtime.keySerde
- key serde used to send key-value pairs,
if not specified the default key serde defined in the configuration will be usedvalSerde
- value serde used to send key-value pairs,
if not specified the default value serde defined in the configuration will be usedtopic
- the topic name; cannot be nullKTable
for the specified topicspublic <K,V> KStream<K,V> merge(KStream<K,V>... streams)
KStream
by merging the given streams.
There are nor ordering guaranteed for records from different streams.