-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathkafka-streams-streams-dsl.html
284 lines (241 loc) · 12.4 KB
/
kafka-streams-streams-dsl.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Kafka Streams Workshop | High-Level Streams DSL</title>
<meta name="description" content="Kafka Streams Workshop | High-Level Streams DSL">
<meta name="author" content="Jacek Laskowski">
<link rel="stylesheet" href="reveal5/dist/reset.css">
<link rel="stylesheet" href="reveal5/dist/reveal.css">
<link rel="stylesheet" href="reveal5/dist/theme/beige.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="reveal5/plugin/highlight/monokai.css">
<!-- Jacek: custom formatting -->
<link rel="stylesheet" href="revealjs-css/jacek.css">
</head>
<body>
<div class="reveal">
<div class="footer">
<footer style="font-size: small;">
© <a href="https://medium.com/@jaceklaskowski">Jacek Laskowski</a> 2022 / <a
href="https://twitter.com/jaceklaskowski">@JacekLaskowski</a>
</footer>
</div>
<div class="slides">
<section class="intro" data-transition="zoom" id="home">
<p>
<img width="14%" style="background:none; border:none; box-shadow:none;" data-src="images/kafka-logo.png">
<img width="10%" src="images/jacek_laskowski_20201229_200x200.png" style="border: 0">
</p>
<h1 style="font-size: 2.44em;">High-Level</h1>
<h1>Streams DSL</h1>
<h4 style="font-size: smaller;">
<a href="https://twitter.com/jaceklaskowski">@jaceklaskowski</a> / <a
href="https://stackoverflow.com/users/1305344/jacek-laskowski">StackOverflow</a> / <a
href="https://github.com/jaceklaskowski">GitHub</a> / <a
href="https://www.linkedin.com/in/jaceklaskowski/">LinkedIn</a>
<br>
The "Internals" Books: <a href="https://books.japila.pl">books.japila.pl</a>
</h4>
</section>
<section id="agenda" style="font-size: 90%" data-markdown>
<textarea data-template>
## Agenda
1. [High-Level Streams DSL](#/intro)
1. [StreamsBuilder](#/streamsbuilder)
1. [KStream](#/kstream)
1. [KTable](#/ktable)
1. [GlobalKTable](#/globalktable)
1. [Consumed](#/consumed)
1. [Produced](#/produced)
1. [KafkaStreams](#/kafkastreams)
1. [Kafka Streams DSL for Scala](#/kafka-streams-dsl-for-scala)
1. [Demo: Processing Record Stream with KStream](#/demo-processing-record-stream-kstream)
1. [Demo: Kafka Streams DSL for Scala](#/demo-kafka-streams-dsl-for-scala)
</textarea>
</section>
<section>
<section style="font-size: 90%" data-markdown id="intro">
<textarea data-template>
## High-Level Streams DSL <small>(1 of 2)</small>
1. **Streams DSL** is a high-level API built on top of the Processor API
1. Built-in abstractions for streams and tables
* KStream
* KTable
* GlobalKTable
1. Declarative, functional programming style
* Stateless transformations (e.g. **map**, **flatMap**, **filter**)
* Stateful transformations (e.g. windowed aggregations)
1. Recommended for most developers, esp. beginners
</textarea>
</section>
<section style="font-size: 90%" data-markdown>
<textarea data-template>
## High-Level Streams DSL <small>(2 of 2)</small>
1. Typical development flow
1. Read input streams (from Kafka topics)
1. Apply transformations
1. Write output streams (to Kafka topics or console)
1. Learn more in [The Internals of Kafka Streams](https://books.japila.pl/kafka-streams-internals/kstream)
</textarea>
</section>
</section>
<section style="font-size: 90%" data-markdown id="streamsbuilder">
<textarea data-template>
## StreamsBuilder
1. **StreamsBuilder** is used to define a (processor) topology
1. Loads a record stream into a KStream
1. Loads a changelog stream into a KTable
1. Loads a changelog stream into a GlobalKTable
1. Streams from records in one or more Kafka topics
1. [StreamsBuilder API](http://kafka.apache.org/33/javadoc/org/apache/kafka/streams/StreamsBuilder.html)
</textarea>
</section>
<section style="font-size: 90%" data-markdown id="kstream">
<textarea data-template>
## KStream
1. **KStream** is an abstraction of a **record stream** (of key-value pairs)
1. Data record represents a self-contained datum in the unbounded data set
1. Data records (in a record stream) are always interpreted as an "INSERT"
* No record replaces an existing row with the same key
1. Examples: credit card transactions, page view events, server log entries
1. [KStream API](http://kafka.apache.org/33/javadoc/org/apache/kafka/streams/kstream/KStream.html)
</textarea>
</section>
<section style="font-size: 90%" data-markdown id="ktable">
<textarea data-template>
## KTable
1. **KTable** is an abstraction of a **changelog stream**
1. Data records (in a record stream) are interpreted as an "UPSERT"
* "UPDATE" of the last value for the same record key
* "INSERT" if a given key doesn't exist yet
1. A record with a **null** value represents a "DELETE" or tombstone for the record's key
1. [KTable API](http://kafka.apache.org/33/javadoc/org/apache/kafka/streams/kstream/KTable.html)
</textarea>
</section>
<section style="font-size: 90%" data-markdown id="globalktable">
<textarea data-template>
## GlobalKTable
1. **GlobalKTable** is an abstraction of a **changelog stream**
* Similarly to KTable
1. Fully replicated per KafkaStreams instance
* Local GlobalKTable instance of each application instance will be populated with data from all partitions of the topic
1. Provides the ability to look up current values of data records by keys
1. Can only be used as right-hand side input for stream-table joins
1. [GlobalKTable API](http://kafka.apache.org/33/javadoc/org/apache/kafka/streams/kstream/GlobalKTable.html)
</textarea>
</section>
<section style="font-size: 90%" data-markdown id="consumed">
<textarea data-template>
## Consumed
1. **Consumed** defines the optional parameters (metadata) that describe how to consume a record stream
* Used in **stream**, **table**, **globalTable**, and **addGlobalStore** operators
1. Learn more in [The Internals of Kafka Streams](https://books.japila.pl/kafka-streams-internals/kstream/Consumed/)
</textarea>
</section>
<section style="font-size: 90%" data-markdown id="produced">
<textarea data-template>
## Produced
1. **Produced** defines the optional parameters (metadata) that describe how to produce a record stream
* Used in **KStream.to** operator
1. Learn more in [The Internals of Kafka Streams](https://books.japila.pl/kafka-streams-internals/kstream/Produced/)
</textarea>
</section>
<section style="font-size: 90%" data-markdown id="kafkastreams">
<textarea data-template>
## KafkaStreams
1. **KafkaStreams** is a Kafka client
1. Performs continuous computation on data from one or more input topics
1. Sends output to zero, one, or more output topics
1. Executes a DAG topology of Processors
1. [KafkaStreams API](http://kafka.apache.org/33/javadoc/org/apache/kafka/streams/KafkaStreams.html)
</textarea>
</section>
<section style="font-size: 90%" data-markdown id="kafka-streams-dsl-for-scala">
<textarea data-template>
## Kafka Streams DSL for Scala
1. **Kafka Streams DSL for Scala** is a wrapper over the existing Java APIs for Kafka Streams DSL
1. Making the Java APIs more usable in Scala
* Better type inferencing
* Enhanced expressiveness
* Less boilerplates
1. Learn more
* [Official documentation](https://kafka.apache.org/33/documentation/streams/developer-guide/dsl-api.html#scala-dsl)
* [The Internals of Kafka Streams](https://books.japila.pl/kafka-streams-internals/scala)
</textarea>
</section>
<section id="demo-processing-record-stream-kstream" data-markdown>
<textarea data-template>
# Demo
## Processing Record Stream <br> with KStream
[Demo: Developing Kafka Streams Application](https://books.japila.pl/kafka-streams-internals/demo/developing-kafka-streams-application/)
</textarea>
</section>
<section id="demo-kafka-streams-dsl-for-scala" data-markdown>
<textarea data-template>
# Demo
## Kafka Streams DSL for Scala
[Scala API for Kafka Streams](https://books.japila.pl/kafka-streams-internals/scala/)
</textarea>
</section>
<section data-markdown id="recap" style="font-size: 90%">
<textarea data-template>
## Recap
1. [High-Level Streams DSL](#/intro)
1. [StreamsBuilder](#/streamsbuilder)
1. [KStream](#/kstream)
1. [KTable](#/ktable)
1. [GlobalKTable](#/globalktable)
1. [Consumed](#/consumed)
1. [Produced](#/produced)
1. [KafkaStreams](#/kafkastreams)
1. [Kafka Streams DSL for Scala](#/kafka-streams-dsl-for-scala)
1. [Demo: Processing Record Stream with KStream](#/demo-processing-record-stream-kstream)
1. [Demo: Kafka Streams DSL for Scala](#/demo-kafka-streams-dsl-for-scala)
</textarea>
</section>
<section style="text-align: left" data-markdown id="questions">
<textarea data-template>
# Questions?
* Read [The Internals of Apache Kafka](https://books.japila.pl/kafka-internals/)
* Read [The Internals of Kafka Streams](https://books.japila.pl/kafka-streams-internals)
* Read [The Internals of ksqlDB](https://books.japila.pl/ksqldb-internals/)
* Follow [@jaceklaskowski](https://twitter.com/jaceklaskowski) on twitter (DMs open)
* Upvote [my questions and answers on StackOverflow](http://stackoverflow.com/users/1305344/jacek-laskowski)
* Contact me at **[email protected]**
</textarea>
</section>
</div>
</div>
<script src="reveal5/dist/reveal.js"></script>
<script src="reveal5/plugin/notes/notes.js"></script>
<script src="reveal5/plugin/markdown/markdown.js"></script>
<script src="reveal5/plugin/highlight/highlight.js"></script>
<script src="reveal5/plugin/zoom/zoom.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
hash: true,
pdf: true,
slideNumber: 'c/t',
showSlideNumber: 'speaker',
// Learn about plugins: https://revealjs.com/plugins/
plugins: [RevealMarkdown, RevealHighlight, RevealNotes, RevealZoom]
});
</script>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-45999426-3', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>