You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by sc...@apache.org on 2025/11/11 09:23:26 UTC
(kafka-site) branch markdown updated: Rehaul of streams intro section (#740)
This is an automated email from the ASF dual-hosted git repository.
schofielaj pushed a commit to branch markdown
in repository https://gitbox.apache.org/repos/asf/kafka-site.git
The following commit(s) were added to refs/heads/markdown by this push:
new 6a9f9f878 Rehaul of streams intro section (#740)
6a9f9f878 is described below
commit 6a9f9f878172f964789a991ae964c28e2f47567d
Author: Harish Vishwanath <ha...@gmail.com>
AuthorDate: Tue Nov 11 01:23:20 2025 -0800
Rehaul of streams intro section (#740)
* Add prev/next navigation buttons sorted by page weights
* Rehaul of streams introduction. Supporting css, shortcodes etc.,
---
assets/scss/_variables_project_after_bs.scss | 52 +++++
content/en/0110/streams/introduction.md | 249 ++++++++++-----------
content/en/10/streams/introduction.md | 273 +++++++++++------------
content/en/11/streams/introduction.md | 296 ++++++++++++-------------
content/en/20/streams/introduction.md | 283 +++++++++++-------------
content/en/21/streams/introduction.md | 283 +++++++++++-------------
content/en/22/streams/introduction.md | 283 +++++++++++-------------
content/en/23/streams/introduction.md | 283 +++++++++++-------------
content/en/24/streams/introduction.md | 283 +++++++++++-------------
content/en/25/streams/introduction.md | 279 +++++++++++-------------
content/en/26/streams/introduction.md | 279 +++++++++++-------------
content/en/27/streams/introduction.md | 279 +++++++++++-------------
content/en/28/streams/introduction.md | 279 +++++++++++-------------
content/en/30/streams/introduction.md | 285 ++++++++++++------------
content/en/31/streams/introduction.md | 285 ++++++++++++------------
content/en/32/streams/introduction.md | 313 +++++++++++++--------------
content/en/33/streams/introduction.md | 313 +++++++++++++--------------
content/en/34/streams/introduction.md | 313 +++++++++++++--------------
content/en/35/streams/introduction.md | 313 +++++++++++++--------------
content/en/36/streams/introduction.md | 313 +++++++++++++--------------
content/en/37/streams/introduction.md | 313 +++++++++++++--------------
content/en/38/streams/introduction.md | 209 +++++++++---------
content/en/39/streams/introduction.md | 209 +++++++++---------
content/en/40/streams/introduction.md | 209 +++++++++---------
content/en/41/streams/introduction.md | 209 +++++++++---------
layouts/docs/baseof.html | 38 ++++
layouts/partials/pager.html | 60 +++++
layouts/shortcodes/about/kstreams-users.html | 18 ++
layouts/shortcodes/carousel-item.html | 14 ++
layouts/shortcodes/carousel.html | 15 ++
layouts/shortcodes/tab.html | 9 +
layouts/shortcodes/tabpane.html | 39 ++++
layouts/shortcodes/youtube.html | 6 +
33 files changed, 3419 insertions(+), 3465 deletions(-)
diff --git a/assets/scss/_variables_project_after_bs.scss b/assets/scss/_variables_project_after_bs.scss
index 03ae0bbd2..d4b53cdc7 100644
--- a/assets/scss/_variables_project_after_bs.scss
+++ b/assets/scss/_variables_project_after_bs.scss
@@ -26,3 +26,55 @@ ul.dropdown-menu {
border: 1px solid #bdbdbd;
}
+/* Pager button explicit neutral styling to avoid theme primary/orange overrides */
+.pager-btn {
+ border: 3px solid #dee2e6 !important; /* gray-300 */
+ color: #343a40 !important; /* text-dark */
+ background-color: #ffffff !important; /* white background */
+ box-shadow: 0 .25rem .5rem rgba(0,0,0,.05) !important; /* subtle */
+}
+.pager-btn:hover {
+ background-color: #f8f9fa !important; /* gray-100 */
+ border-color: #ced4da !important; /* gray-400 */
+ text-decoration: none !important;
+}
+.pager-btn:focus {
+ outline: 0 !important;
+ box-shadow: 0 0 0 .2rem rgba(206,212,218,.5) !important; /* gray focus ring */
+}
+
+.carousel-item {
+ min-height: 400px;
+
+ .youtube-video {
+ max-width: 800px;
+ margin: 0 auto;
+ }
+
+ h4 {
+ color: var(--td-body-text-color);
+ }
+}
+
+.carousel-control-prev,
+.carousel-control-next {
+ width: 5%;
+ opacity: 0.8;
+
+ &:hover {
+ opacity: 1;
+ }
+}
+
+/* Make carousel nav buttons more obvious */
+.carousel-control-prev-icon,
+.carousel-control-next-icon {
+ background-color: rgba(0, 0, 0, 0.65);
+ border-radius: 50%;
+ padding: 1.1rem;
+ box-shadow: 0 .5rem 1rem rgba(0, 0, 0, 0.15);
+}
+.carousel-control-prev:hover .carousel-control-prev-icon,
+.carousel-control-next:hover .carousel-control-next-icon {
+ background-color: rgba(0, 0, 0, 0.85);
+}
\ No newline at end of file
diff --git a/content/en/0110/streams/introduction.md b/content/en/0110/streams/introduction.md
index c537f59f1..190303b33 100644
--- a/content/en/0110/streams/introduction.md
+++ b/content/en/0110/streams/introduction.md
@@ -31,131 +31,138 @@ type: docs
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KStreamBuilder;
- import org.apache.kafka.streams.kstream.KTable;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties config = new Properties();
- config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- KStreamBuilder builder = new KStreamBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count("Counts");
- wordCounts.to(Serdes.String(), Serdes.Long(), "WordsWithCountsTopic");
-
- KafkaStreams streams = new KafkaStreams(builder, config);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KStreamBuilder;
+ import org.apache.kafka.streams.kstream.KTable;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties config = new Properties();
+ config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ KStreamBuilder builder = new KStreamBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count("Counts");
+ wordCounts.to(Serdes.String(), Serdes.Long(), "WordsWithCountsTopic");
+
+ KafkaStreams streams = new KafkaStreams(builder, config);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KStreamBuilder;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.ValueMapper;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties config = new Properties();
- config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- KStreamBuilder builder = new KStreamBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count("Counts");
- wordCounts.to(Serdes.String(), Serdes.Long(), "WordsWithCountsTopic");
-
- KafkaStreams streams = new KafkaStreams(builder, config);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KStreamBuilder;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties config = new Properties();
+ config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ KStreamBuilder builder = new KStreamBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count("Counts");
+ wordCounts.to(Serdes.String(), Serdes.Long(), "WordsWithCountsTopic");
+
+ KafkaStreams streams = new KafkaStreams(builder, config);
+ streams.start();
}
-
-
-
- import java.lang.Long
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.common.serialization._
- import org.apache.kafka.streams._
- import org.apache.kafka.streams.kstream.{KStream, KStreamBuilder, KTable}
-
- import scala.collection.JavaConverters.asJavaIterableConverter
-
- object WordCountApplication {
-
- def main(args: Array[String]) {
- val config: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass)
- p.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass)
- p
- }
-
- val builder: KStreamBuilder = new KStreamBuilder()
- val textLines: KStream[String, String] = builder.stream("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+").toIterable.asJava)
- .groupBy((_, word) => word)
- .count("Counts")
- wordCounts.to(Serdes.String(), Serdes.Long(), "WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder, config)
- streams.start()
-
- Runtime.getRuntime.addShutdownHook(new Thread(() => {
- streams.close(10, TimeUnit.SECONDS)
- }))
+
+ }
+
+
+
+ import java.lang.Long
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+ import java.util.concurrent.TimeUnit
+
+ import org.apache.kafka.common.serialization._
+ import org.apache.kafka.streams._
+ import org.apache.kafka.streams.kstream.{KStream, KStreamBuilder, KTable}
+
+ import scala.collection.JavaConverters.asJavaIterableConverter
+
+ object WordCountApplication {
+
+ def main(args: Array[String]) {
+ val config: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass)
+ p.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass)
+ p
}
-
+
+ val builder: KStreamBuilder = new KStreamBuilder()
+ val textLines: KStream[String, String] = builder.stream("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+").toIterable.asJava)
+ .groupBy((_, word) => word)
+ .count("Counts")
+ wordCounts.to(Serdes.String(), Serdes.Long(), "WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder, config)
+ streams.start()
+
+ Runtime.getRuntime.addShutdownHook(new Thread(() => {
+ streams.close(10, TimeUnit.SECONDS)
+ }))
}
-
+
+ }
+```
+{{% /tab %}}
+{{< /tabpane >}}
+
## See how Kafka Streams is being used
diff --git a/content/en/10/streams/introduction.md b/content/en/10/streams/introduction.md
index 3bb916b0d..e5f91b856 100644
--- a/content/en/10/streams/introduction.md
+++ b/content/en/10/streams/introduction.md
@@ -73,144 +73,147 @@ Trivago is a global hotel search platform. We are focused on reshaping the way t
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties config = new Properties();
- config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), config);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties config = new Properties();
+ config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), config);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties config = new Properties();
- config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), config);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties config = new Properties();
+ config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), config);
+ streams.start();
}
-
-
-
- import java.lang.Long
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.common.serialization._
- import org.apache.kafka.common.utils.Bytes
- import org.apache.kafka.streams._
- import org.apache.kafka.streams.kstream.{KStream, KTable, Materialized, Produced}
- import org.apache.kafka.streams.state.KeyValueStore
-
- import scala.collection.JavaConverters.asJavaIterableConverter
-
- object WordCountApplication {
-
- def main(args: Array[String]) {
- val config: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass)
- p.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass)
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder()
- val textLines: KStream[String, String] = builder.stream("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+").toIterable.asJava)
- .groupBy((_, word) => word)
- .count(Materialized.as("counts-store").asInstanceOf[Materialized[String, Long, KeyValueStore[Bytes, Array[Byte]]]])
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.`with`(Serdes.String(), Serdes.Long()))
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), config)
- streams.start()
-
- Runtime.getRuntime.addShutdownHook(new Thread(() => {
- streams.close(10, TimeUnit.SECONDS)
- }))
+
+ }
+
+
+
+ import java.lang.Long
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+ import java.util.concurrent.TimeUnit
+
+ import org.apache.kafka.common.serialization._
+ import org.apache.kafka.common.utils.Bytes
+ import org.apache.kafka.streams._
+ import org.apache.kafka.streams.kstream.{KStream, KTable, Materialized, Produced}
+ import org.apache.kafka.streams.state.KeyValueStore
+
+ import scala.collection.JavaConverters.asJavaIterableConverter
+
+ object WordCountApplication {
+
+ def main(args: Array[String]) {
+ val config: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass)
+ p.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass)
+ p
}
-
- }
-
- * [Documentation](/documentation)
+ val builder: StreamsBuilder = new StreamsBuilder()
+ val textLines: KStream[String, String] = builder.stream("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+").toIterable.asJava)
+ .groupBy((_, word) => word)
+ .count(Materialized.as("counts-store").asInstanceOf[Materialized[String, Long, KeyValueStore[Bytes, Array[Byte]]]])
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.`with`(Serdes.String(), Serdes.Long()))
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), config)
+ streams.start()
+
+ Runtime.getRuntime.addShutdownHook(new Thread(() => {
+ streams.close(10, TimeUnit.SECONDS)
+ }))
+ }
+ }
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/11/streams/introduction.md b/content/en/11/streams/introduction.md
index 46070e3a9..73455eb80 100644
--- a/content/en/11/streams/introduction.md
+++ b/content/en/11/streams/introduction.md
@@ -45,173 +45,155 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties config = new Properties();
- config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), config);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties config = new Properties();
+ config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), config);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties config = new Properties();
- config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), config);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties config = new Properties();
+ config.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ config.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ config.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), config);
+ streams.start();
}
-
-
-
- import java.lang.Long
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.common.serialization._
- import org.apache.kafka.common.utils.Bytes
- import org.apache.kafka.streams._
- import org.apache.kafka.streams.kstream.{KStream, KTable, Materialized, Produced}
- import org.apache.kafka.streams.state.KeyValueStore
-
- import scala.collection.JavaConverters.asJavaIterableConverter
-
- object WordCountApplication {
-
- def main(args: Array[String]) {
- val config: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass)
- p.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass)
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder()
- val textLines: KStream[String, String] = builder.stream("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+").toIterable.asJava)
- .groupBy((_, word) => word)
- .count(Materialized.as("counts-store").asInstanceOf[Materialized[String, Long, KeyValueStore[Bytes, Array[Byte]]]])
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.`with`(Serdes.String(), Serdes.Long()))
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), config)
- streams.start()
-
- Runtime.getRuntime.addShutdownHook(new Thread(() => {
- streams.close(10, TimeUnit.SECONDS)
- }))
+
+ }
+
+
+
+ import java.lang.Long
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+ import java.util.concurrent.TimeUnit
+
+ import org.apache.kafka.common.serialization._
+ import org.apache.kafka.common.utils.Bytes
+ import org.apache.kafka.streams._
+ import org.apache.kafka.streams.kstream.{KStream, KTable, Materialized, Produced}
+ import org.apache.kafka.streams.state.KeyValueStore
+
+ import scala.collection.JavaConverters.asJavaIterableConverter
+
+ object WordCountApplication {
+
+ def main(args: Array[String]) {
+ val config: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass)
+ p.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass)
+ p
}
-
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ val builder: StreamsBuilder = new StreamsBuilder()
+ val textLines: KStream[String, String] = builder.stream("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+").toIterable.asJava)
+ .groupBy((_, word) => word)
+ .count(Materialized.as("counts-store").asInstanceOf[Materialized[String, Long, KeyValueStore[Bytes, Array[Byte]]]])
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.`with`(Serdes.String(), Serdes.Long()))
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), config)
+ streams.start()
+
+ Runtime.getRuntime.addShutdownHook(new Thread(() => {
+ streams.close(10, TimeUnit.SECONDS)
+ }))
+ }
+ }
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/20/streams/introduction.md b/content/en/20/streams/introduction.md
index f7471243d..588082509 100644
--- a/content/en/20/streams/introduction.md
+++ b/content/en/20/streams/introduction.md
@@ -45,166 +45,145 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/21/streams/introduction.md b/content/en/21/streams/introduction.md
index 33c427104..68897692f 100644
--- a/content/en/21/streams/introduction.md
+++ b/content/en/21/streams/introduction.md
@@ -45,166 +45,145 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/22/streams/introduction.md b/content/en/22/streams/introduction.md
index 70e5be695..2b5119769 100644
--- a/content/en/22/streams/introduction.md
+++ b/content/en/22/streams/introduction.md
@@ -45,166 +45,145 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/23/streams/introduction.md b/content/en/23/streams/introduction.md
index 8707b9fde..19a650a8f 100644
--- a/content/en/23/streams/introduction.md
+++ b/content/en/23/streams/introduction.md
@@ -45,166 +45,145 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/24/streams/introduction.md b/content/en/24/streams/introduction.md
index 78513ab2a..2cbd9bdab 100644
--- a/content/en/24/streams/introduction.md
+++ b/content/en/24/streams/introduction.md
@@ -45,166 +45,145 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/25/streams/introduction.md b/content/en/25/streams/introduction.md
index 364bfd011..1868229e8 100644
--- a/content/en/25/streams/introduction.md
+++ b/content/en/25/streams/introduction.md
@@ -45,163 +45,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/26/streams/introduction.md b/content/en/26/streams/introduction.md
index 7b381808a..826829ef9 100644
--- a/content/en/26/streams/introduction.md
+++ b/content/en/26/streams/introduction.md
@@ -45,163 +45,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/27/streams/introduction.md b/content/en/27/streams/introduction.md
index f6d7b4daa..6e3c68008 100644
--- a/content/en/27/streams/introduction.md
+++ b/content/en/27/streams/introduction.md
@@ -45,163 +45,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/28/streams/introduction.md b/content/en/28/streams/introduction.md
index 644fa6f9a..bdb3c5c55 100644
--- a/content/en/28/streams/introduction.md
+++ b/content/en/28/streams/introduction.md
@@ -45,163 +45,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
+
+ }
+
+
+ import org.apache.kafka.common.serialization.Serdes;
+ import org.apache.kafka.common.utils.Bytes;
+ import org.apache.kafka.streams.KafkaStreams;
+ import org.apache.kafka.streams.StreamsBuilder;
+ import org.apache.kafka.streams.StreamsConfig;
+ import org.apache.kafka.streams.kstream.KStream;
+ import org.apache.kafka.streams.kstream.KTable;
+ import org.apache.kafka.streams.kstream.ValueMapper;
+ import org.apache.kafka.streams.kstream.KeyValueMapper;
+ import org.apache.kafka.streams.kstream.Materialized;
+ import org.apache.kafka.streams.kstream.Produced;
+ import org.apache.kafka.streams.state.KeyValueStore;
+
+ import java.util.Arrays;
+ import java.util.Properties;
+
+ public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
}
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
+ }
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/30/streams/introduction.md b/content/en/30/streams/introduction.md
index fd7e7da53..a56a01834 100644
--- a/content/en/30/streams/introduction.md
+++ b/content/en/30/streams/introduction.md
@@ -45,163 +45,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/31/streams/introduction.md b/content/en/31/streams/introduction.md
index 953bd0922..5ec841bd1 100644
--- a/content/en/31/streams/introduction.md
+++ b/content/en/31/streams/introduction.md
@@ -45,163 +45,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
+{{< about/kstreams-users >}}
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
-
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/32/streams/introduction.md b/content/en/32/streams/introduction.md
index 47398c556..fae158661 100644
--- a/content/en/32/streams/introduction.md
+++ b/content/en/32/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,163 +63,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/33/streams/introduction.md b/content/en/33/streams/introduction.md
index b218b470a..60f7c6fec 100644
--- a/content/en/33/streams/introduction.md
+++ b/content/en/33/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,163 +63,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/34/streams/introduction.md b/content/en/34/streams/introduction.md
index a2271aca4..ed31d5884 100644
--- a/content/en/34/streams/introduction.md
+++ b/content/en/34/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,163 +63,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/35/streams/introduction.md b/content/en/35/streams/introduction.md
index 446c96bf0..341b4373a 100644
--- a/content/en/35/streams/introduction.md
+++ b/content/en/35/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,163 +63,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/36/streams/introduction.md b/content/en/36/streams/introduction.md
index 68692c621..b86dd6231 100644
--- a/content/en/36/streams/introduction.md
+++ b/content/en/36/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,163 +63,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/37/streams/introduction.md b/content/en/37/streams/introduction.md
index ee5c1709a..fe25e3953 100644
--- a/content/en/37/streams/introduction.md
+++ b/content/en/37/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,163 +63,144 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Java 7 Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.ValueMapper;
- import org.apache.kafka.streams.kstream.KeyValueMapper;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(new ValueMapper<String, Iterable<String>>() {
- @Override
- public Iterable<String> apply(String textLine) {
- return Arrays.asList(textLine.toLowerCase().split("\W+"));
- }
- })
- .groupBy(new KeyValueMapper<String, String, String>() {
- @Override
- public String apply(String key, String word) {
- return word;
- }
- })
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
-
-
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+ Java 7" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+
+
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.ValueMapper;
+import org.apache.kafka.streams.kstream.KeyValueMapper;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(new ValueMapper<String, Iterable<String>>() {
+ @Override
+ public Iterable<String> apply(String textLine) {
+ return Arrays.asList(textLine.toLowerCase().split("\W+"));
+ }
+ })
+ .groupBy(new KeyValueMapper<String, String, String>() {
+ @Override
+ public String apply(String key, String word) {
+ return word;
+ }
+ })
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+
+
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/38/streams/introduction.md b/content/en/38/streams/introduction.md
index 9e4aad836..7066f76d8 100644
--- a/content/en/38/streams/introduction.md
+++ b/content/en/38/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,111 +63,92 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/39/streams/introduction.md b/content/en/39/streams/introduction.md
index f80f4ef7b..fd65dbb61 100644
--- a/content/en/39/streams/introduction.md
+++ b/content/en/39/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,111 +63,92 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java 8+ Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java 8+" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/40/streams/introduction.md b/content/en/40/streams/introduction.md
index 40bb23161..f2ffb5e1c 100644
--- a/content/en/40/streams/introduction.md
+++ b/content/en/40/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,111 +63,92 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/content/en/41/streams/introduction.md b/content/en/41/streams/introduction.md
index 3c9bd480a..5c6847b35 100644
--- a/content/en/41/streams/introduction.md
+++ b/content/en/41/streams/introduction.md
@@ -14,21 +14,33 @@ type: docs
Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka's server-side cluster technology.
-## Intro to Streams
+
-{{< youtube "ni3XPsYC5cQ" >}}
+
-## Creating a Streams Application
+
-{{< youtube "9ZhsnXM2OVM" >}}
+
-## Transforming Data Pt. 1
-{{< youtube "SYmqwvE8umM" >}}
+## Tour of the Streams API
+
+{{< carousel >}}
+{{< carousel-item title="1. Intro to Streams" active="true" >}}
+{{% youtube "ni3XPsYC5cQ" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="2. Creating a Streams Application" >}}
+{{% youtube "9ZhsnXM2OVM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="3. Transforming Data Pt. 1" >}}
+{{% youtube "SYmqwvE8umM" %}}
+{{< /carousel-item >}}
+{{< carousel-item title="4. Transforming Data Pt. 2" >}}
+{{% youtube "Vk55Kl9x_Fw" %}}
+{{< /carousel-item >}}
+{{< /carousel >}}
-## Transforming Data Pt. 2
-{{< youtube "Vk55Kl9x_Fw" >}}
* * *
@@ -51,111 +63,92 @@ Kafka Streams is a client library for building applications and microservices, w
## Kafka Streams use cases
-[ ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)
-
-[The New York Times uses Apache Kafka ](https://open.nytimes.com/publishing-with-apache-kafka-at-the-new-york-times-7f0e3b7d2077)and the Kafka Streams to store and distribute, in real-time, published content to the various applications and systems that make it available to the readers.
-
-[ ](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/)
-
-As the leading online fashion retailer in Europe, Zalando uses Kafka as an ESB (Enterprise Service Bus), which helps us in transitioning from a monolithic to a micro services architecture. Using Kafka for processing [ event streams](https://www.confluent.io/blog/ranking-websites-real-time-apache-kafkas-streams-api/) enables our technical team to do near-real time business intelligence.
-
-[ ](https://engineering.linecorp.com/en/blog/detail/80)
-
-[LINE uses Apache Kafka](https://engineering.linecorp.com/en/blog/detail/80) as a central datahub for our services to communicate to one another. Hundreds of billions of messages are produced daily and are used to execute various business logic, threat detection, search indexing and data analysis. LINE leverages Kafka Streams to reliably transform and filter topics enabling sub topics consumers can efficiently consume, meanwhile retaining easy maintainability thanks to its sophisticated [...]
-[ ](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996)
+{{< about/kstreams-users >}}
-[Pinterest uses Apache Kafka and the Kafka Streams](https://medium.com/@Pinterest_Engineering/using-kafka-streams-api-for-predictive-budgeting-9f58d206c996) at large scale to power the real-time, predictive budgeting system of their advertising infrastructure. With Kafka Streams, spend predictions are more accurate than ever.
-
-[ ](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-Rabobank is one of the 3 largest banks in the Netherlands. Its digital nervous system, the Business Event Bus, is powered by Apache Kafka. It is used by an increasing amount of financial processes and services, one of which is Rabo Alerts. This service alerts customers in real-time upon financial events and is [built using Kafka Streams.](https://www.confluent.io/blog/real-time-financial-alerts-rabobank-apache-kafkas-streams-api/)
-
-[ ](https://speakerdeck.com/xenji/kafka-and-debezium-at-trivago-code-dot-talks-2017-edition)
-
-Trivago is a global hotel search platform. We are focused on reshaping the way travelers search for and compare hotels, while enabling hotel advertisers to grow their businesses by providing access to a broad audience of travelers via our websites and apps. As of 2017, we offer access to approximately 1.8 million hotels and other accommodations in over 190 countries. We use Kafka, Kafka Connect, and Kafka Streams to [enable our developers](https://speakerdeck.com/xenji/kafka-and-debezium [...]
## Hello Kafka Streams
The code example below implements a WordCount application that is elastic, highly scalable, fault-tolerant, stateful, and ready to run in production at large scale
-Java Scala
-
-
- import org.apache.kafka.common.serialization.Serdes;
- import org.apache.kafka.common.utils.Bytes;
- import org.apache.kafka.streams.KafkaStreams;
- import org.apache.kafka.streams.StreamsBuilder;
- import org.apache.kafka.streams.StreamsConfig;
- import org.apache.kafka.streams.kstream.KStream;
- import org.apache.kafka.streams.kstream.KTable;
- import org.apache.kafka.streams.kstream.Materialized;
- import org.apache.kafka.streams.kstream.Produced;
- import org.apache.kafka.streams.state.KeyValueStore;
-
- import java.util.Arrays;
- import java.util.Properties;
-
- public class WordCountApplication {
-
- public static void main(final String[] args) throws Exception {
- Properties props = new Properties();
- props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
- props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
- props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
- props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
-
- StreamsBuilder builder = new StreamsBuilder();
- KStream<String, String> textLines = builder.stream("TextLinesTopic");
- KTable<String, Long> wordCounts = textLines
- .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
- .groupBy((key, word) -> word)
- .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
- wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
-
- KafkaStreams streams = new KafkaStreams(builder.build(), props);
- streams.start();
- }
-
- }
-
-
- import java.util.Properties
- import java.util.concurrent.TimeUnit
-
- import org.apache.kafka.streams.kstream.Materialized
- import org.apache.kafka.streams.scala.ImplicitConversions._
- import org.apache.kafka.streams.scala._
- import org.apache.kafka.streams.scala.kstream._
- import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
-
- object WordCountApplication extends App {
- import Serdes._
-
- val props: Properties = {
- val p = new Properties()
- p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
- p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
- p
- }
-
- val builder: StreamsBuilder = new StreamsBuilder
- val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
- val wordCounts: KTable[String, Long] = textLines
- .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
- .groupBy((_, word) => word)
- .count()(Materialized.as("counts-store"))
- wordCounts.toStream.to("WordsWithCountsTopic")
-
- val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
- streams.start()
-
- sys.ShutdownHookThread {
- streams.close(10, TimeUnit.SECONDS)
- }
- }
-
- * [Documentation](/documentation)
- * [Kafka Streams](/streams)
-
+{{< tabpane >}}
+{{% tab header="Java" %}}
+```java
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.Bytes;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.KTable;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.kstream.Produced;
+import org.apache.kafka.streams.state.KeyValueStore;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+public class WordCountApplication {
+
+ public static void main(final String[] args) throws Exception {
+ Properties props = new Properties();
+ props.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application");
+ props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092");
+ props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+ props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass());
+
+ StreamsBuilder builder = new StreamsBuilder();
+ KStream<String, String> textLines = builder.stream("TextLinesTopic");
+ KTable<String, Long> wordCounts = textLines
+ .flatMapValues(textLine -> Arrays.asList(textLine.toLowerCase().split("\W+")))
+ .groupBy((key, word) -> word)
+ .count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("counts-store"));
+ wordCounts.toStream().to("WordsWithCountsTopic", Produced.with(Serdes.String(), Serdes.Long()));
+
+ KafkaStreams streams = new KafkaStreams(builder.build(), props);
+ streams.start();
+ }
+
+}
+```
+{{% /tab %}}
+{{% tab header="Scala" %}}
+```scala
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+import org.apache.kafka.streams.kstream.Materialized
+import org.apache.kafka.streams.scala.ImplicitConversions._
+import org.apache.kafka.streams.scala._
+import org.apache.kafka.streams.scala.kstream._
+import org.apache.kafka.streams.{KafkaStreams, StreamsConfig}
+
+object WordCountApplication extends App {
+ import Serdes._
+
+ val props: Properties = {
+ val p = new Properties()
+ p.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-application")
+ p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka-broker1:9092")
+ p
+ }
+
+ val builder: StreamsBuilder = new StreamsBuilder
+ val textLines: KStream[String, String] = builder.stream[String, String]("TextLinesTopic")
+ val wordCounts: KTable[String, Long] = textLines
+ .flatMapValues(textLine => textLine.toLowerCase.split("\W+"))
+ .groupBy((_, word) => word)
+ .count()(Materialized.as("counts-store"))
+ wordCounts.toStream.to("WordsWithCountsTopic")
+
+ val streams: KafkaStreams = new KafkaStreams(builder.build(), props)
+ streams.start()
+
+ sys.ShutdownHookThread {
+ streams.close(10, TimeUnit.SECONDS)
+ }
+}
+```
+{{% /tab %}}
+{{< /tabpane >}}
diff --git a/layouts/docs/baseof.html b/layouts/docs/baseof.html
new file mode 100644
index 000000000..62af26325
--- /dev/null
+++ b/layouts/docs/baseof.html
@@ -0,0 +1,38 @@
+<!doctype html>
+<html itemscope itemtype="http://schema.org/WebPage"
+ {{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
+ {{ with .Site.Language.Lang }} lang="{{ . }}" {{- end }} {{/**/ -}}
+ class="no-js">
+ <head>
+ {{ partial "head.html" . }}
+ </head>
+ <body class="td-{{ .Kind }}{{ with .Page.Params.body_class }} {{ . }}{{ end }}">
+ <header>
+ {{ partial "navbar.html" . }}
+ </header>
+ <div class="container-fluid td-outer">
+ <div class="td-main">
+ <div class="row flex-xl-nowrap">
+ <aside class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
+ {{ partial "sidebar.html" . }}
+ </aside>
+ <aside class="d-none d-xl-block col-xl-2 td-sidebar-toc d-print-none">
+ {{ partial "page-meta-links.html" . }}
+ {{ partial "toc.html" . }}
+ {{ partial "taxonomy_terms_clouds.html" . }}
+ </aside>
+ <main class="col-12 col-md-9 col-xl-8 ps-md-5" role="main">
+ {{ partial "version-banner.html" . }}
+ {{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
+ {{ block "main" . }}{{ end }}
+ {{ partial "pager.html" . }}
+ </main>
+ </div>
+
+ </div>
+ {{ partial "footer.html" . }}
+ </div>
+ {{ partial "scripts.html" . }}
+ <script src="/js/carousel-video.js"></script>
+ </body>
+</html>
\ No newline at end of file
diff --git a/layouts/partials/pager.html b/layouts/partials/pager.html
new file mode 100644
index 000000000..763a088cf
--- /dev/null
+++ b/layouts/partials/pager.html
@@ -0,0 +1,60 @@
+{{- if .Site.Params.ui.showPrevNext -}}
+ {{- $current := . -}}
+ {{- $section := .CurrentSection -}}
+ {{- if $section -}}
+ {{- $pages := $section.RegularPages.ByWeight -}}
+ {{- $s := newScratch -}}
+ {{- $s.Set "index" -1 -}}
+ {{- range $i, $p := $pages -}}
+ {{- if eq $p.RelPermalink $current.RelPermalink -}}
+ {{- $s.Set "index" $i -}}
+ {{- end -}}
+ {{- end -}}
+ {{- $i := $s.Get "index" -}}
+ {{- if ge $i 0 -}}
+ {{- if gt $i 0 -}}
+ {{- $s.Set "prev" (index $pages (sub $i 1)) -}}
+ {{- end -}}
+ {{- if lt (add $i 1) (len $pages) -}}
+ {{- $s.Set "next" (index $pages (add $i 1)) -}}
+ {{- end -}}
+ <div class="td-page-meta mb-3 mt-4 d-print-none">
+ <nav class="d-flex justify-content-between align-items-center gap-3">
+ <div class="d-flex flex-column align-items-start">
+ {{- with $s.Get "prev" -}}
+ <a class="btn pager-btn rounded-3 fw-semibold py-2 px-3 d-inline-flex align-items-center gap-2"
+ style="min-width: 12rem;"
+ href="{{ .RelPermalink }}"
+ rel="prev"
+ aria-label="Previous: {{ .Title }}"
+ >
+ <span class="fw-semibold text-dark">‹ Previous:</span>
+ <span class="text-dark text-truncate d-inline-block" style="max-width: 18rem;">
+ {{ .LinkTitle | default .Title }}
+ </span>
+ </a>
+ {{- end -}}
+ </div>
+ <div class="ms-auto d-flex flex-column align-items-end">
+ {{- with $s.Get "next" -}}
+ <a class="btn pager-btn rounded-3 fw-semibold py-2 px-3 d-inline-flex align-items-center gap-2"
+ style="min-width: 12rem;"
+ href="{{ .RelPermalink }}"
+ rel="next"
+ aria-label="Next: {{ .Title }}"
+ >
+ <span class="fw-semibold text-dark">Next:</span>
+ <span class="text-dark text-truncate d-inline-block text-end" style="max-width: 18rem;">
+ {{ .LinkTitle | default .Title }}
+ </span>
+ <span class="fw-semibold text-dark">›</span>
+ </a>
+ {{- end -}}
+ </div>
+ </nav>
+ </div>
+ {{- end -}}
+ {{- end -}}
+{{- end -}}
+
+
diff --git a/layouts/shortcodes/about/kstreams-users.html b/layouts/shortcodes/about/kstreams-users.html
new file mode 100644
index 000000000..91587ac2d
--- /dev/null
+++ b/layouts/shortcodes/about/kstreams-users.html
@@ -0,0 +1,18 @@
+{{ $testimonials := site.Data.testimonials -}}
+<div class="row c-testimonials">
+{{- range $testimonials -}}
+ {{- if or (in .description "Kafka Streams") (in (lower (.link | default "")) "zalando") -}}
+ {{ $img := printf "/images/powered-by/%s" .logo | relURL -}}
+ {{ $bgColor := .logoBgColor | default "#FFFFFF" -}}
+ <div class="col-12 col-sm-6 col-md-4 col-lg-3 c-testimonials__testimonial">
+ <a href="{{ .link }}" target="_blank" rel="noopener">
+ <span class="grid__item__logo" style="background-image: url({{ $img }}); background-color: {{ $bgColor }};"></span>
+ </a>
+ <p class="c-testimonials__description">
+ {{- .description | safeHTML -}}
+ </p>
+ </div>
+ {{- end -}}
+{{ end -}}
+</div>
+
diff --git a/layouts/shortcodes/carousel-item.html b/layouts/shortcodes/carousel-item.html
new file mode 100644
index 000000000..645088314
--- /dev/null
+++ b/layouts/shortcodes/carousel-item.html
@@ -0,0 +1,14 @@
+{{- $title := .Get "title" -}}
+{{- $active := .Get "active" | default "" -}}
+{{- $activeClass := cond (eq $active "true") "active" "" -}}
+<div class="carousel-item {{ $activeClass }} text-center py-4">
+ {{- if $title -}}
+ <h4 class="mb-3">{{ $title }}</h4>
+ {{- end -}}
+ <div class="d-flex justify-content-center">
+ <div class="w-100" style="max-width: 900px;">
+ {{- .Inner -}}
+ </div>
+ </div>
+</div>
+
diff --git a/layouts/shortcodes/carousel.html b/layouts/shortcodes/carousel.html
new file mode 100644
index 000000000..6ef62c567
--- /dev/null
+++ b/layouts/shortcodes/carousel.html
@@ -0,0 +1,15 @@
+{{- $id := .Get "id" | default (printf "carousel-%d" .Ordinal) -}}
+<div id="{{ $id }}" class="carousel slide mb-4" data-bs-interval="false">
+ <div class="carousel-inner">
+ {{- .Inner -}}
+ </div>
+ <button class="carousel-control-prev" type="button" data-bs-target="#{{ $id }}" data-bs-slide="prev">
+ <span class="carousel-control-prev-icon" aria-hidden="true"></span>
+ <span class="visually-hidden">Previous</span>
+ </button>
+ <button class="carousel-control-next" type="button" data-bs-target="#{{ $id }}" data-bs-slide="next">
+ <span class="carousel-control-next-icon" aria-hidden="true"></span>
+ <span class="visually-hidden">Next</span>
+ </button>
+</div>
+
diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html
new file mode 100644
index 000000000..3e7341d09
--- /dev/null
+++ b/layouts/shortcodes/tab.html
@@ -0,0 +1,9 @@
+{{- /* Register child tab under a page-scoped key unique to this parent */ -}}
+{{- $header := .Get "header" | default "Tab" -}}
+{{- $content := .Inner | markdownify -}}
+{{- $key := (.Page.Scratch.Get "tabpane_current") | default (printf "tabs-%d" .Parent.Ordinal) -}}
+{{- $tabs := .Page.Scratch.Get $key | default (slice) -}}
+{{- $tabs = $tabs | append (dict "header" $header "content" $content) -}}
+{{- .Page.Scratch.Set $key $tabs -}}
+
+
diff --git a/layouts/shortcodes/tabpane.html b/layouts/shortcodes/tabpane.html
new file mode 100644
index 000000000..ec42ea1fc
--- /dev/null
+++ b/layouts/shortcodes/tabpane.html
@@ -0,0 +1,39 @@
+{{- /* Page-scoped key to collect tabs for this pane */ -}}
+{{- $paneId := printf "tabs-%d" .Ordinal -}}
+{{- /* Make this pane the current target for child tabs */ -}}
+{{- $.Page.Scratch.Set "tabpane_current" $paneId -}}
+{{- /* Evaluate children to let them register their content under the key */ -}}
+{{- .Inner -}}
+{{- $tabs := $.Page.Scratch.Get $paneId | default (slice) -}}
+{{- /* Clear the current pointer */ -}}
+{{- $.Page.Scratch.Delete "tabpane_current" -}}
+
+<ul class="nav nav-tabs" id="{{ $paneId }}" role="tablist">
+ {{- range $i, $t := $tabs -}}
+ <li class="nav-item">
+ <button class="nav-link {{ if eq $i 0 }}active{{ end }}"
+ id="{{ $paneId }}-{{ printf "%02d" $i }}-tab"
+ data-bs-toggle="tab"
+ data-bs-target="#{{ $paneId }}-{{ printf "%02d" $i }}"
+ role="tab"
+ aria-controls="{{ $paneId }}-{{ printf "%02d" $i }}"
+ aria-selected="{{ if eq $i 0 }}true{{ else }}false{{ end }}">
+ {{- index $t "header" -}}
+ </button>
+ </li>
+ {{- end -}}
+</ul>
+
+<div class="tab-content" id="{{ $paneId }}-content">
+ {{- range $i, $t := $tabs -}}
+ <div class="tab-pane fade {{ if eq $i 0 }}show active{{ end }}"
+ id="{{ $paneId }}-{{ printf "%02d" $i }}"
+ role="tabpanel"
+ aria-labelled-by="{{ $paneId }}-{{ printf "%02d" $i }}-tab"
+ tabindex="2">
+ {{- (index $t "content") | safeHTML -}}
+ </div>
+ {{- end -}}
+</div>
+
+
diff --git a/layouts/shortcodes/youtube.html b/layouts/shortcodes/youtube.html
new file mode 100644
index 000000000..d9bfdf040
--- /dev/null
+++ b/layouts/shortcodes/youtube.html
@@ -0,0 +1,6 @@
+{{- $id := .Get 0 -}}
+<div style="position: relative; width: 100%; max-width: 900px; padding-bottom: 56.25%; height: 0; overflow: hidden;">
+ <iframe src="https://www.youtube.com/embed/{{ $id }}?enablejsapi=1" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" allowfullscreen title="YouTube Video"></iframe>
+</div>
+
+