We can create a basic kafka environment by using docker's docker-compose
command.
docker-compose up -f ./kafka
For next points we will be using Kafka Command-line Tools
kafka-topics \
--zookeeper localhost:2181 \
--create \
--topic t1 \
--partitions 1 \
--replication-factor 1
kafka-console-producer --broker-list localhost:9092 --topic t1
The producer emits a message every 5 seconds. The consumer simply reads the messages from the topic and outputs them to the console along with their offset.
Variable | Description |
---|---|
KAFKA_HOST |
Kafka broker host string, multiple comma separated hosts can be given |
KAFKA_GROUP_ID |
Name of consumer group |
KAFKA_TOPIC |
Topic to read messages from |
KAFKA_HOST=localhost:9092
KAFKA_GROUP_ID=test
KAFKA_TOPIC=t1
Check each directory for a guide with further information