The producer includes a retry mechanism to handle transient errors when producing messages to the Kafka topic. This ensures that if a message fails to be sent initially, the producer will retry sending it a configurable number of times before giving up.
The consumer also includes a retry mechanism for sending emails via SMTP. If an email fails to send, the consumer will retry sending the email a configurable number of times before logging the failure and moving on. Additionally, the consumer includes a retry mechanism for committing messages to Kafka. If a commit fails, it will retry a configurable number of times before logging the failure.
- Navigate to the kafka directory and run the kafka docker compose:
cd kafka && docker compose up
- Access the Kafka container:
docker exec -it kafka_1 sh
- create topic kafka
kafka-topics --create --bootstrap-server localhost:9093 --replication-factor 1 --partitions 1 --topic sendmail --command-config /etc/kafka/config/config.properties
- Copy the .env.example file to .env in the producer directory:
cp .env.example .env
- Update the .env file with your configuration settings.
- Navigate to the producer directory and run the producer:
cd producer && go run main.go
- Copy the .env.example file to .env in the consumer directory:
cp .env.example .env
- Update the .env file with your configuration settings. You can use Mailtrap or other SMTP services.
- Navigate to the consumer directory and run the consumer:
cd consumer && go run main.go