Kafka Demonstration - Tuong-Nguyen/Angular-D3-Cometd GitHub Wiki
Start the server
- Zookeeper:
bin/zookeeper-server-start.sh config/zookeeper.properties
Zookeeper is listening on port 2181 (default). We can check by using telnet to connect to that service.
- Broker:
bin/kafka-server-start.sh config/server.properties
Broker listens on port 9092 (default). We can check by using telnet to connect to that service.
Demo
Topic
- Create a Topic on Zookeeper
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic my_topic
- List Topics in on Zookeeper
bin/kafka-topics.sh --list --zookeeper localhost:2181
- Delete Topic
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic my_topic
Producer
Start a producer application and send message to broker on a topic
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic my_topic
Send message by typing a sentence with Enter.
This is a message
This is another message
Consumer
Start a consumer application for receiving messages of a topic
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic my_topic --from-beginning
Consumer will poll the broker and display message.
Additional Tools
- Telnet:
- Install telnet client on Windows 10
dism /online /Enable-Feature /FeatureName:TelnetClient
- Putty