Skip to content

This repository contains a Spring Boot application integrated with Apache Kafka for real-time messaging

License

Notifications You must be signed in to change notification settings

athrocks/Spring-Apache-Kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apache Kafka with Spring Boot

This repository demonstrates how to integrate Apache Kafka with Spring Boot. It covers Kafka producer, consumer, topic configuration, JSON serialization, and REST APIs for message publishing.

Branches Structure

  • 01-Initialization - Setting up Kafka in a Spring Boot project.

  • 02-Consumer-Producer-Configuration - Configuring Kafka producer and consumer.

  • 03-Kafka-Topic - Creating and managing Kafka topics.

  • 04-Kafka-Producer - Implementing Kafka producers.

  • 05-API-Send-Message - Sending messages using REST APIs.

  • 06-Kafka-Consumer - Implementing Kafka consumers.

  • 07-JSON-Serializer-Deserializer - Handling JSON messages with Kafka.

Prerequisites

  • Java 17+

  • Apache Kafka

  • Spring Boot 3+

  • Docker (optional for containerized setup)

Installation & Setup

  1. Start Kafka (if not running):

    bin\windows\kafka-server-start.bat config\server.properties
  2. Clone the repository:

    git clone https://github.com/athrocks/Spring-Apache-Kafka.git
    cd Spring-Apache-Kafka
  3. Run the Spring Boot application:

    mvn spring-boot:run

REST APIs

Send String Message

Endpoint:

GET http://localhost:8080/api/v1/kafka/publish?message=hello%20world

Response:

"Message sent to the Kafka topic"

Send JSON Message

Endpoint:

POST http://localhost:8080/api/v1/kafka/publish

Request Body:

{
  "id": 1,
  "firstName": "John",
  "lastName": "Doe"
}

Response:

"Json Message sent to the Kafka topic"

User Model

public class User {
    private int id;
    private String firstName;
    private String lastName;

    // Getters and Setters
}

License

This project is open-source and available under the MIT License.

About

This repository contains a Spring Boot application integrated with Apache Kafka for real-time messaging

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages