Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 790 Bytes

File metadata and controls

36 lines (24 loc) · 790 Bytes

Produce and consumer messages to/from Kafka using Python

Prerequisites

  • To have started Kafka using Docker Compose as showed in the lab 02-eCommerce_microservices
  • On the host, to have mapped localhost and kafka to 127.0.0.1, for example
$ echo "127.0.0.1 kafka localhost" | sudo tee -a /etc/hosts)

Run the lab

Install dependencies

$ pip install -r requirements.txt

Start consumer

$ python kafka-consumer.py --config_file consumer.conf

Produce messages

$ python kafka-producer.py --config_file producer.conf

In the case you want to consume from the beginning of the topic/partition

$ python kafka-consumer.py --config_file consumer.conf --reset