This repository contains a simple Apache Kafka learning project implemented using Spring Boot. The project consists of two Spring Boot applications: a producer and a consumer.
The producer application provides an HTTP endpoint (/send
) that allows users to send messages to a Kafka topic. When a message is sent to this endpoint, the producer sends the message to the Kafka topic.
To send a message to Kafka using the producer application:
-
Start the producer application by running
ProducerApplication.java
. -
Make a POST request to the
/send
endpoint with a message as a request parameter:curl -X POST "http://localhost:8080/send?message=YourMessageHere"
Replace YourMessageHere with the message you want to send to Kafka.
The consumer application uses a Kafka listener (@KafkaListener) to consume messages from the Kafka topic. When a message is received, it logs the message content.
To consume messages from Kafka using the consumer application:
Start the consumer application by running ConsumerApplication.java.
Messages sent to the Kafka topic by the producer application will be received and logged by the consumer.
Java Development Kit (JDK) installed on your system. Apache Kafka installed and running locally or on a reachable server. Configuration Ensure that the Kafka broker address is correctly configured in both producer and consumer applications. You can configure Kafka-related properties in the application.properties or application.yml files.
Spring Boot Spring Kafka