-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopic
executable file
·49 lines (38 loc) · 1 KB
/
topic
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
#!/bin/bash
if [[ "$KAFKAS" == '' ]]; then
echo 'KAFKAS env var not set'
exit 1
fi
# topic list
# topic create hithere
# topic delete hithere
# topic write hithere
# key
# value
# ^D
# topic read hithere
operation="$1"
topic="$2"
set -x
case "$operation" in
list | ls)
kafka-topics.sh --bootstrap-server $KAFKAS --list
;;
create | add | mk | new)
kafka-topics.sh --bootstrap-server $KAFKAS --create --topic "$topic" --partitions 3 --replication-factor 3
;;
delete | remove | rm | del)
kafka-topics.sh --bootstrap-server $KAFKAS --delete --topic "$topic"
;;
describe | desc | show )
kafka-topics.sh --bootstrap-server $KAFKAS --describe --topic "$topic"
;;
write)
kafka-console-producer.sh --bootstrap-server $KAFKAS --topic $topic
;;
read)
kafka-console-consumer.sh --bootstrap-server $KAFKAS --topic $topic --from-beginning --property print.timestamp=true
;;
*)
;;
esac