This project is a simple application to demonstrate basic messaging concepts with Kafka using Rust, Tokio, and the rdkafka library. It includes a producer that sends messages to a Kafka topic and a consumer that consumes those messages.
git clone https://github.com/loanmatteusz/simple-use-messaging-rdkafka.git
cd simple-use-messaging-rdkafka
Before running the application, you need to start Kafka and Zookeeper using Docker Compose:
docker-compose up -d
With the Kafka and Zookeeper containers running, you can execute the Rust application:
cargo run --quiet
This will send a message to the test-topic and consume that same message.
- producer.rs: Contains the code to create a producer and send messages to Kafka.
- consumer.rs: Contains the code to create a consumer and read messages from Kafka.
- main.rs: The entry point of the application, which creates a producer to send a message and starts a consumer to read it.
- Kafka Topic:
test-topic
- Bootstrap Servers:
localhost:9092
- Consumer Group:
test-group
The docker-compose.yml sets up two services:
- zookeeper: Necessary for Kafka to operate.
- kafka: The Kafka broker that will be used to send and receive messages.
If you encounter connection errors, such as Connection refused, ensure that Kafka is running correctly on port 9092 and that localhost is the correct address.
docker-compose down
docker-compose up -d
This project is a study and was written following this video made by the YouTube user Semicolon
.