https://github.com/juancarlosjr97/kafka-python-basic-example
Kafka Python Basic Example for macOS
https://github.com/juancarlosjr97/kafka-python-basic-example
Last synced: 2 months ago
JSON representation
Kafka Python Basic Example for macOS
- Host: GitHub
- URL: https://github.com/juancarlosjr97/kafka-python-basic-example
- Owner: juancarlosjr97
- Created: 2020-11-03T10:26:22.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-04T01:44:34.000Z (about 3 years ago)
- Last Synced: 2025-01-28T22:38:02.711Z (4 months ago)
- Language: Python
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kafka Basic Example Python
These are the instructions to run Kafka on a macOS.
## Prerequisites
We need to have installed the following services:
- [Homebrew](https://brew.sh/)
- [Python 3 or above](https://www.python.org/)### Installation
1. Install Java 8 SDK using homebrew
```
brew cask install homebrew/cask-versions/adoptopenjdk8
```2. Install Kafka using homebre
```
brew install kafka
```3. Python Environment
```
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```## Start Zookeeper and Kafka as a service
```
brew services start zookeeper
brew services start kafka
```## Stop Zookeeper and Kafka as a service
```
brew services stop zookeeper
brew services stop kafka
```## Creating a topic on Kafka
```
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic ${TOPIC_NAME}
```## Start Consumer
The virtual environment needs to be activated.
```
python consumer.py --topic=TOPIC
```## Send a message a Producer
The virtual environment needs to be activated.
```
python producer.py --topic=TOPIC --message=MESSAGE --server=SERVER
```