mirror of https://github.com/apache/kafka.git
MINOR: Update Streams quickstart to create output topic with compaction enabled
Author: Matthias J. Sax <matthias@confluent.io> Reviewers: Michael G. Noll <michael@confluent.io>, Guozhang Wang <wangguoz@gmail.com> Closes #3949 from mjsax/minor-update-streams-quickstart
This commit is contained in:
parent
a0f533266a
commit
a96e28eac1
|
@ -129,12 +129,18 @@ Next, we create the input topic named <b>streams-plaintext-input</b> and the out
|
||||||
--partitions 1 \
|
--partitions 1 \
|
||||||
--topic streams-plaintext-input
|
--topic streams-plaintext-input
|
||||||
Created topic "streams-plaintext-input".
|
Created topic "streams-plaintext-input".
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
Note: we create the output topic with compaction enabled because the output stream is a changelog stream
|
||||||
|
(cf. <a href="#anchor-changelog-output">explanation of application output</a> below).
|
||||||
|
|
||||||
|
<pre class="brush: bash;">
|
||||||
> bin/kafka-topics.sh --create \
|
> bin/kafka-topics.sh --create \
|
||||||
--zookeeper localhost:2181 \
|
--zookeeper localhost:2181 \
|
||||||
--replication-factor 1 \
|
--replication-factor 1 \
|
||||||
--partitions 1 \
|
--partitions 1 \
|
||||||
--topic streams-wordcount-output
|
--topic streams-wordcount-output \
|
||||||
|
--config cleanup.policy=compact
|
||||||
Created topic "streams-wordcount-output".
|
Created topic "streams-wordcount-output".
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
@ -263,6 +269,7 @@ hello kafka streams
|
||||||
join kafka summit
|
join kafka summit
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<a name="anchor-changelog-output"></a>
|
||||||
The <b>streams-wordcount-output</b> topic will subsequently show the corresponding updated word counts (see last three lines):
|
The <b>streams-wordcount-output</b> topic will subsequently show the corresponding updated word counts (see last three lines):
|
||||||
|
|
||||||
<pre class="brush: bash;">
|
<pre class="brush: bash;">
|
||||||
|
|
|
@ -496,6 +496,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
We can also write the <code>counts</code> KTable's changelog stream back into another Kafka topic, say <code>streams-wordcount-output</code>.
|
We can also write the <code>counts</code> KTable's changelog stream back into another Kafka topic, say <code>streams-wordcount-output</code>.
|
||||||
|
Because the result is a changelog stream, the output topic <code>streams-wordcount-output</code> should be configured with log compaction enabled.
|
||||||
Note that this time the value type is no longer <code>String</code> but <code>Long</code>, so the default serialization classes are not viable for writing it to Kafka anymore.
|
Note that this time the value type is no longer <code>String</code> but <code>Long</code>, so the default serialization classes are not viable for writing it to Kafka anymore.
|
||||||
We need to provide overridden serialization methods for <code>Long</code> types, otherwise a runtime exception will be thrown:
|
We need to provide overridden serialization methods for <code>Long</code> types, otherwise a runtime exception will be thrown:
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue