Simplified example
[demos/kafka/deduplication] / README.sh
1 #!/bin/bash
2
3 if [ "$1" = "cleanup" ]
4 then
5   docker-compose down
6   mvn clean
7   exit
8 fi
9
10 mvn package
11
12 docker build -t juplo/deduplicator:streams .
13
14 docker-compose up -d zookeeper kafka
15
16 while ! [[ $(zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]]; do echo "Waiting for kafka..."; sleep 1; done
17
18 kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic input
19 kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic output
20
21 docker-compose up -d deduplicator
22 cat data.txt | kafkacat -K: -b localhost:9092 -t input
23 sleep 5
24
25 kafkacat -C -b localhost:9092 -t input -e | wc -l
26 kafkacat -C -b localhost:9092 -t output -e | wc -l
27
28 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^0 > result_0.txt
29 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^1 > result_1.txt
30 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^2 > result_2.txt
31 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^3 > result_3.txt
32 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^4 > result_4.txt
33 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^5 > result_5.txt
34 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^6 > result_6.txt