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":"[email protected]",
"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}
In order to run it you can make:
docker compose up