-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stream Data Processing.txt
33 lines (27 loc) · 1.23 KB
/
Stream Data Processing.txt
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
# Create some data in a file
echo -e "all streams lead to kafka\nhello kafka streams\njoin kafka summit" > file-input.txt
# Send data to new topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic streams-file-input
# Send data to the topic
kafka-console-producer.sh --broker-list localhost:9092 --topic streams-file-input < file-input.txt
# Run WordCount application, this will terminate after a few seconds
kafka-run-class.sh org.apache.kafka.streams.examples.wordcount.WordCountDemo
# Inspect the output by reading from the topic where the data was written
# Use the built-in String and Long deserializers
kafka-console-consumer.sh --bootstrap-server localhost:9092 \
--topic streams-wordcount-output \
--from-beginning \
--formatter kafka.tools.DefaultMessageFormatter \
--property print.key=true \
--property print.value=true \
--property key.deserializer=org.apache.kafka.common.serialization.StringDeserializer \
--property value.deserializer=org.apache.kafka.common.serialization.LongDeserializer
# Output should look like the following
all 1
lead 1
to 1
hello 1
streams 2
join 1
kafka 3
summit 1