Skip to content

POC made in Java to learn the basics of Kafka in a project

Notifications You must be signed in to change notification settings

renatompf/poc_spring_kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poc_spring_kafka

Description

POC made in Java to learn how to setup a project using Kafka, Zookeeper and Spring using MongoDB to handle all the data.

In this project, there are two endpoints, but they are very similar.

One of the endpoints have the purpose to send string in Kafka messages by making the following GET Request:

localhost:8080/kafka/producer

Where in the body a String is sent.

The other endpoint, as I said before, it's very similar. It as the purpose of send classes in Json in Kafka messages. You can using it by making the following POST request:

localhost:8080/kafka/producer/user

I'll leave an example of the body the user should use:

{
    "name":"John Smith",
    "dateOfBirth":"2000-01-01T10:30:00.000Z",
    "email":"john_smith@mail.com",
    "phoneNumber":911111111
}

The way the messages are consumed by the Kafka Consumer is the same for both since it receives just a string and depending if it can to serialize it to a structure of type User, it will say that received a User, otherwise it will say that received a simple message.

To check if your user was saved correctly, then you can do the following:
Or get all users:

localhost:8080/saved-users


Or get one user by his email:

localhost:8080/saved-users/{userEmail}

How to run it:

In order to run it you can make:

docker compose up

About

POC made in Java to learn the basics of Kafka in a project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published