Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shaikrasheed99/golang-kafka-producer-consumer
Kafka Producer & Consumer applications in Golang.
https://github.com/shaikrasheed99/golang-kafka-producer-consumer
docker docker-compose docker-kafka golang-kafka kafka kafka-consumer kafka-go kafka-producer kafka-producer-consumer
Last synced: about 2 months ago
JSON representation
Kafka Producer & Consumer applications in Golang.
- Host: GitHub
- URL: https://github.com/shaikrasheed99/golang-kafka-producer-consumer
- Owner: shaikrasheed99
- License: mit
- Created: 2023-11-06T09:48:56.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-13T04:10:09.000Z (about 1 year ago)
- Last Synced: 2023-11-13T05:24:54.365Z (about 1 year ago)
- Topics: docker, docker-compose, docker-kafka, golang-kafka, kafka, kafka-consumer, kafka-go, kafka-producer, kafka-producer-consumer
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kafka Producer & Consumer applications in Golang
This is a simple example of a Kafka producer and consumer written in Go using the Sarama library. The producer sends messages to a Kafka topic, and the consumer reads and processes those messages.
## Prerequisites
Before running this application, ensure that you have the following installed:
* Go (Golang) - You can download and install Go from the [official website](https://golang.org/dl/).
* Kafka - You need a running Kafka broker. You can download and set up Apache Kafka from the [official website](https://kafka.apache.org/downloads).## Setup
1. Clone this repository to your local machine
```bash
git clone https://github.com/shaikrasheed99/golang-kafka-producer-consumer.git
```2. Install the required Go packages
```bash
go get .
```3. Update the Kafka broker URL in the producer and consumer code if your Kafka broker is running on a different host and port.
4. Build the producer and consumer executables
```bash
go build producer.go
go build consumer.go
```## Running the Producer
1. Start the Kafka producer by running the producer executable
```bash
./producer
```2. The producer will prompt you to enter messages. Type a message and press Enter. To exit the producer, type "exit" and press Enter.
3. The producer will send the messages to the Kafka topic specified in the code (default is "test").
## Running the Consumer
1. Start the Kafka consumer by running the consumer executable
```bash
./consumer
```2. The consumer will subscribe to the Kafka topic specified in the code (default is "test") and start reading messages.
3. The consumer will print received messages to the console, or it will log any errors encountered during message processing.
4. To stop the consumer, press `Ctrl+C`.