{"id":16891565,"url":"https://github.com/kasramp/spring-kafka-test","last_synced_at":"2025-06-26T21:33:25.630Z","repository":{"id":44345471,"uuid":"299428222","full_name":"kasramp/spring-kafka-test","owner":"kasramp","description":"Spring Kafka with unit test example","archived":false,"fork":false,"pushed_at":"2024-08-18T20:31:36.000Z","size":60,"stargazers_count":50,"open_issues_count":0,"forks_count":26,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T04:34:44.023Z","etag":null,"topics":["embedded-kafka","kafka","kafka-test","spring-boot","spring-boot-kafka","spring-kafka-test","testcontainers"],"latest_commit_sha":null,"homepage":"https://www.geekyhacker.com/test-spring-kafka-consumer-and-producer-with-embeddedkafka/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kasramp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-28T20:47:54.000Z","updated_at":"2025-04-06T14:42:12.000Z","dependencies_parsed_at":"2024-10-27T12:12:58.480Z","dependency_job_id":"753bac6f-6f6b-42d2-9a30-fd1fa2d1912d","html_url":"https://github.com/kasramp/spring-kafka-test","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kasramp/spring-kafka-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasramp%2Fspring-kafka-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasramp%2Fspring-kafka-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasramp%2Fspring-kafka-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasramp%2Fspring-kafka-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kasramp","download_url":"https://codeload.github.com/kasramp/spring-kafka-test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasramp%2Fspring-kafka-test/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262145176,"owners_count":23265883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded-kafka","kafka","kafka-test","spring-boot","spring-boot-kafka","spring-kafka-test","testcontainers"],"created_at":"2024-10-13T17:07:51.938Z","updated_at":"2025-06-26T21:33:25.588Z","avatar_url":"https://github.com/kasramp.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Kafka test example\n\nSpring Kafka example with JUnit 5 using EmbeddedKafka/`spring-kafka-test` and also using [Testcontainers](https://www.testcontainers.org/).\n\nFor the tutorials check the links below,\n\n- [Test Spring Kafka consumer and producer with EmbeddedKafka](https://www.geekyhacker.com/test-spring-kafka-consumer-and-producer-with-embeddedkafka/)\n- [Write Kafka integration test with Testcontainers](https://www.geekyhacker.com/write-kafka-integration-test-with-testcontainers/)\n- [Database migration with Spring Boot and Flyway](https://www.geekyhacker.com/database-migration-with-spring-boot-and-flyway/)\n- [Spring Boot MySQL integration tests with Testcontainers](https://www.geekyhacker.com/spring-boot-mysql-integration-tests-with-testcontainers/)\n- [Spring Boot Swagger documentation using OpenAPI](https://www.geekyhacker.com/spring-boot-swagger-documentation-using-openapi/)\n- [Disable Springdoc OpenAPI Swagger in production](https://www.geekyhacker.com/disable-springdoc-openapi-swagger-in-production/)\n- [How to hide an endpoint in Springdoc OpenAPI](https://www.geekyhacker.com/how-to-hide-an-endpoint-in-springdoc-openapi/)\n\n## How to run\n\nFirst start the docker-compose which contains ZooKeeper, Kafka, Kafdrop, and MySQL.\n\n```bash\n$ docker-compose -f docker-compose.yml up -d\n```\n\nOnce all the containers are healthy start the application,\n\n```bash\n$ ./mvnw spring-boot:run\n```\n\nOpen the browser `localhost:8080/apidocs`. \n\nYou can interact with the `random` API to create a random user which then will be sent to Kafka and consumed by the consumer (see [`consumer/UserKafkaListener.java`](https://github.com/kasramp/spring-kafka-test/blob/master/src/main/java/com/madadipouya/springkafkatest/consumer/UserKafkaListener.java) file) and finally saves into the database.\n\nTo see whether the message has been sent to Kafka, open your browser `http://localhost:8085/topic/com.madadipouya.kafka.use` (Kafdrop environment), \nyou should be able to see all messages that sent to `kafka.user` topic.\n\nTo run Flyway migration scripts only run,\n\n```bash\n$ ./mvnw flyway:migrate\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasramp%2Fspring-kafka-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkasramp%2Fspring-kafka-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasramp%2Fspring-kafka-test/lists"}