This Springboot application is designed to update user information and integrate with Kafka for event processing. The application follows a series of steps to fetch user data from the GitHub API, create a payload, and store it in a database. It then utilizes Kafka to send the payload as an event named "UserInfoChanged" to the "users" topic.
-
Sending User Information Update Request
- Send a PUT request to the
/users/:user_id
endpoint of the Springboot application to update user information.
- Send a PUT request to the
-
Fetching User Data
- The application initiates a GET request to the GitHub API, using the
user_id
as a path parameter, to retrieve information starting from thesince
variable. - The application receives the next 30 users, starting from the given
since
variable value. - From the response, the
user_name
is extracted from the first element, representing the user with the givenuser_id
. - Three additional API calls are made to the GitHub API using the
user_name
to fetch the user's basic details, list of followers, and list of repositories. This is handled by theGitHubService
.
- The application initiates a GET request to the GitHub API, using the
-
Creating the Payload
- Using the responses obtained from the previous API calls and the request body of the user request made in step 1, the application creates a payload.
- The payload is then stored in the database for further processing.
-
Triggering Kafka Event
- User sends a POST request to the
/produce/:user_id
endpoint with an empty body. - The application retrieves the payload associated with the given
user_id
from the request and sends it to theEventProducerService
for further processing.
- User sends a POST request to the
-
Event Processing with Kafka
- When the
EventProducerService
receives the payload, it creates aUserInfoChanged
event. - The event is then sent to the Kafka server using the "users" topic for further event processing.
- When the
-
Clone the project from GitHub:
git clone https://github.com/ShakyaPr/User-Info-Update-Springboot-App-Kafka.git
cd User-Info-Update-Springboot-App-Kafka/
-
Deploy PostgreSQL Database, Kafka Server, and Kafdrop using Docker:
docker run --name postgres -e POSTGRES_PASSWORD=admin12#$ -d -p 5432:5432 postgres
ocker run --net=host -p 2181:2181 -p 9092:9092 -e ADVERTISED_HOST=127.0.0.1 -e NUM_PARTITIONS=10 --name kafka_server johnnypark/kafka-zookeeper
-
Ensure that port 8000 is available on your system.
-
Run the application:
./mvnw spring-boot:run