Skip to content

mark-poussard/spring-flink-test

Repository files navigation

Spring Flink Testing

This is a test project to run flink from Spring boot.

The scenario explored here is to implement an analytics counter on GET queries, while avoiding updates to the database on every query.

To achieve this we log each event on Kafka, aggregate these events through Flink and update the database with the aggregated response, allowing a single database update for multiple view events.

How to run

./gradlew run

How to use

Hit the below endpoint to simulate a view event

GET http://localhost:8080/api/note/1

The response object will contain the current number of aggregated views and the number of database updates

{
    "id": 1,
    "description": "description",
    "content": "content",
    "views": 44,
    "dbUpdatesCount": 5,
    "viewsUpdateIdempotencyKey": "7d86264e-0e82-465f-8334-456bdae54424",
    "createdAt": "2025-02-21T15:00:08.000+00:00"
}

Cheatsheet

Docker

Force recreate

docker-compose up --force-recreate

List docker process

sudo docker ps -a

Stop docker process

sudo docker stop $PROCESS_ID

Remove docker process

sudo docker rm $PROCESS_ID

Remove all docker process

docker rm -v -f $(docker ps -qa)

Connect to docker database

docker exec -it mysql_container mysql -uroot -proot mydb

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published