An open API service indexing awesome lists of open source software.

https://github.com/isaacmaffeis/spring-boot-kafka

This repository contains a Spring Boot application that helped me to learn about Apache Kafka.
https://github.com/isaacmaffeis/spring-boot-kafka

kafka postman spring-boot

Last synced: 5 months ago
JSON representation

This repository contains a Spring Boot application that helped me to learn about Apache Kafka.

Awesome Lists containing this project

README

          

## How to Start the application
Open Docker Desktop, go to the root directory of the project in the terminal and in order to run the containers of Kafka and Zookeeper digit:
```shell
docker compose up
```
run the project using any IDE or use maven with the following instruction:
```shell
mvn clean install
mvn spring-boot:run
```
use [Postman](https://web.postman.co//) to test the API, some examples:
```http request
POST /visit HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Content-Length: 49

{
"customerId":null,
"dateTime":null
}
```
```http request
POST /visit HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Content-Length: 108

{
"customerId":"webID001-bf3c-4b21-8ea4-8bcc99a634d4",
"dateTime":"2024-04-06T17:36:55.1313334"
}
```

## Kafka Basics
🔗 Kafka Docker Compose Quickstart: https://developer.confluent.io/quickstart/kafka-local/
### Create and start containers
```shell
docker compose up
```

### Create Topic
```shell
docker exec broker kafka-topics --bootstrap-server broker:9092 --create --topic "customer.visit"
```

### Command Line Consumer
```shell
docker exec --interactive --tty broker kafka-console-consumer --bootstrap-server broker:9092 --topic "customer.visit" --from-beginning
```

### Command Line Producer
```shell
docker exec --interactive --tty broker kafka-console-producer --bootstrap-server broker:9092 --topic "customer.visit"
```

## Kafka Web UI
[Kafdrop](https://github.com/obsidiandynamics/kafdrop) is a web UI for viewing Kafka topics and browsing consumer groups. The tool displays information such as
brokers, topics, partitions, consumers, and lets you view messages.

Open a browser and navigate to http://localhost:9000.

![KafdropImage](https://github.com/isaacmaffeis/Spring-boot-kafka/assets/28917454/94357957-898a-49c8-b045-87cf59876d62)

## Dependencies

### Jackson
In order to use Jackson and the module for Java8 DateTimes, use the
following dependencies:
```xml

com.fasterxml.jackson.core
jackson-databind

com.fasterxml.jackson.datatype
jackson-datatype-jsr310

```

### Model Mapper
In order to use the model mapper module for implementing the mappers, use the
following dependency:
```xml

org.modelmapper
modelmapper
3.0.0

```