Project at: https://github.com/howardchn/hello-kafka
This is used for setting up a Kafka environment with a simple producer and continuously sending a number per second. You could just build your own client to consume the predefined topics foobar
.
Quick Setup
For quick start, only the following commands will be ready to go.
Note: before running the following commands, make sure the following items are installed.
Prerequisite
- docker CE or EE
- docker composer
- ports
2181
,9092
and29092
are not in using
Launch The Service
1 | cd [your work directory] |
Then wait about 15
seconds, the zookeeper
, kafka
and default simple producer
are ready.
Build Your Own Producer
The integrated producer has hard-coded topic name foolbar
nad the key is Null
(not defined), the content is an incremented number
and the sending interval is 1 second
. Seems lots of restriction inside. The following steps will help to customize your own producer and docker images.
- modify
main.py
which is the implementation of the producer - build docker image with
docker build -t [your producer image name] .
- replace the producer image
howardch/hello-kafka-producer
with[your producer image name]
indocker-compose.yaml
file - everything is set, execute command
docker-compose up -d
to run your own environment