- Notifications
You must be signed in to change notification settings - Fork4
Account Service - Spring, Kafka Streams sample application that allows users to sign up and retrieve account details and statistics. This PoC demonstrates how to run multiple Kafka Streams instances (with different consumer groups) inside single Spring Boot application.
License
rbiedrawa/spring-kafka-streams-protobuf-testcontainers-demo
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Account Service - Spring, Kafka Streams sample application that allows users to Sign up and retrieve account details and statistics.
This project demonstrates how to runmultiple Kafka Streams instances (with different consumer groups) insidesingle Spring Boot application.
- Patterns, technologies and concepts demonstrated here
- Architecture
- Getting Started
- Deployment
- References
- License
- Testcontainers for Kafka streams integration tests.
- Multiple KStreams inside single boot application.
- Kafka protobuf integration.
- Dynamic property binding in Spring Framework.
- gRPC for handling commands (CreateAccount).
- gRPC client via BloomRPC application.
- Interactive queries (kafka state store integration).
- Query endpoints for account details and statistics.
- REST endpoints for printing kstream topology details.
- Separating unit and integration tests with gradle.
- Docker, docker compose integration.
- Custom gradle task for printing docker image name and sample docker-compose file.
- Faker with scheduling setup for generating dummy data, activated by
dummy_data_gen
spring profile. - Custom lombok configuration.
- Java 11
- Docker
- Kafka
- Schema Registry
StartKafka broker andSchema Registry using
Confluent Community
orConfluent Platform
components.- Confluent community:
docker-compose -f ./docker/local/docker-compose.yml up -d
- Confluent Platform:
docker-compose -f ./docker/confluent-platform/docker-compose.yml up -d
- Confluent community:
Check if all containers started, using
docker-compose ps
command.# Sample output for Confluent Platform Name Command State Ports ----------------------------------------------------------------------------------------------------broker /etc/confluent/docker/run Up 0.0.0.0:9092->9092/tcp, 0.0.0.0:9101->9101/tcpcontrol-center /etc/confluent/docker/run Up 0.0.0.0:9021->9021/tcp rest-proxy /etc/confluent/docker/run Up 0.0.0.0:8082->8082/tcp schema-registry /etc/confluent/docker/run Up 0.0.0.0:8081->8081/tcp zookeeper /etc/confluent/docker/run Up 0.0.0.0:2181->2181/tcp, 2888/tcp, 3888/tcp
StartAccount Service
./gradlew bootRun
CheckCreate Account flow
- Import proto files intoBloomRPC client.
- Choose6565 as gRPC server port.
- Create new account usingAccountService.Create rpc call.
# Sample request body{"email":"newAccount@test.com","countryCode":"GB","type": 2}
- Get account id from response
# Sample response body{"id":"519faeb7-ccdf-49dd-95a4-3e2a6ac8ad13","email":"newAccount@test.com","countryCode":"GB","type":"PREMIUM","createdDate": {"seconds":"1616860904","nanos": 644947000 }}
- Test interactive queries using REST endpoints.
- Get account details from
accounts.store
state store (use account id retrieved before):curl -X GET --location"http://localhost:8080/api/v1/accounts/519faeb7-ccdf-49dd-95a4-3e2a6ac8ad13"
- Get account statistics for 'GB' countryCode:
curl -X GET --location"http://localhost:8080/api/v1/statistics/countries/GB/accounts"
- Get account details from
Analise kafka streams topology:
- Get all available topologies.
curl -X GET --location"http://localhost:8080/topologies"
- Print topology foraccounts-per-country kstream.
curl -X GET --location"http://localhost:8080/topologies/accounts-per-country"
- Print topology diagram, visithttps://zz85.github.io/kafka-streams-viz/ page.
- Get all available topologies.
- Unit test (TopologyTestDriver) examples may be found undersrc/test/.
- Integration test (Testcontainers) examples may be found undersrc/integrationTest/.
Docker compose file with instructions are kept indocker subdirectory.
- Kafka Streams Topology Visualizer
- Spring for Apache Kafka
- Quick Start for Apache Kafka using Confluent Platform (Docker)
- DynamicPropertySource in Spring Framework
- Testcontainers: singleton-containers
- Testcontainers: Kafka Modules Reference Guide
- Testing a streams application
- BloomRPC
- Java Faker
- Gradle Test Logger Plugin
- Protobuf Plugin for Gradle
Distributed under the MIT License. SeeLICENSE
for more information.
About
Account Service - Spring, Kafka Streams sample application that allows users to sign up and retrieve account details and statistics. This PoC demonstrates how to run multiple Kafka Streams instances (with different consumer groups) inside single Spring Boot application.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.