{"id":26856716,"url":"https://github.com/luismr/kafka-springboot-blueprint","last_synced_at":"2026-05-04T22:42:56.124Z","repository":{"id":285291630,"uuid":"957630691","full_name":"luismr/kafka-springboot-blueprint","owner":"luismr","description":"This project demonstrates three different Kafka delivery modes using Spring Boot:","archived":false,"fork":false,"pushed_at":"2025-03-30T23:12:30.000Z","size":13,"stargazers_count":13,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-04T22:42:55.151Z","etag":null,"topics":["java","java-17","java17","juni5","junit","mockito","spring","springboot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luismr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-30T20:29:37.000Z","updated_at":"2025-07-22T07:49:40.000Z","dependencies_parsed_at":"2025-03-30T21:28:09.706Z","dependency_job_id":"db550ca7-0c1d-43b1-9288-620b0d244c00","html_url":"https://github.com/luismr/kafka-springboot-blueprint","commit_stats":null,"previous_names":["luismr/kafka-springboot-blueprint"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luismr/kafka-springboot-blueprint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fkafka-springboot-blueprint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fkafka-springboot-blueprint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fkafka-springboot-blueprint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fkafka-springboot-blueprint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luismr","download_url":"https://codeload.github.com/luismr/kafka-springboot-blueprint/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismr%2Fkafka-springboot-blueprint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32628211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["java","java-17","java17","juni5","junit","mockito","spring","springboot"],"created_at":"2025-03-31T00:23:21.988Z","updated_at":"2026-05-04T22:42:56.108Z","avatar_url":"https://github.com/luismr.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kafka Spring Boot Blueprint\n\n![Java](https://img.shields.io/badge/Java-17-blue)\n![Maven](https://img.shields.io/badge/Maven-3-blue)\n![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.2.3-blue)\n![JUnit](https://img.shields.io/badge/JUnit-5-blue)\n![Mockito](https://img.shields.io/badge/Mockito-blue)\n![Kafka](https://img.shields.io/badge/Kafka-3.x-red)\n\n\nThis project demonstrates three different Kafka delivery modes using Spring Boot:\n- At-most-once delivery\n- At-least-once delivery\n- Exactly-once delivery\n\n## Getting Started\n\n### Cloning the Repository\n\n```bash\ngit clone git@github.com:luismr/kafka-springboot-blueprint.git\ncd kafka-springboot-blueprint\n```\n\n## Project Structure\n\nThe project consists of the following main components:\n\n1. **Abstract Producer**: `AbstractKafkaProducer` - Base class providing common functionality for all producers\n2. **Delivery Mode Implementations**:\n   - `AtMostOnceProducer` - Messages may be lost but never delivered more than once\n   - `AtLeastOnceProducer` - Messages will be delivered at least once, with retries\n   - `ExactlyOnceProducer` - Messages will be delivered exactly once, with no duplicates\n\n3. **Configuration**:\n   - `KafkaConfig` - Configures Kafka templates and topics\n   - `application.yml` - Application properties with detailed comments\n\n## Prerequisites\n\n- Java 17 or later\n- Maven 3.6 or later\n- Apache Kafka 3.x\n- Spring Boot 3.x\n\n## Configuration\n\nThe application can be configured using `application.yml` or environment variables.\n\n### Using application.yml\n\n```yaml\nspring:\n  kafka:\n    bootstrap-servers: localhost:9092\n    producer:\n      key-serializer: org.apache.kafka.common.serialization.StringSerializer\n      value-serializer: org.apache.kafka.common.serialization.StringSerializer\n      # Delivery mode specific configurations\n      at-most-once:\n        acks: 0\n      at-least-once:\n        acks: all\n        retries: 3\n        retry-backoff-ms: 1000\n      exactly-once:\n        acks: all\n        enable.idempotence: true\n        transaction.timeout.ms: 30000\n        max.in.flight.requests.per.connection: 5\n```\n\n### Using Environment Variables\n\nYou can configure the Kafka bootstrap servers using environment variables on different operating systems:\n\n#### Linux/macOS\n```bash\nexport SPRING_KAFKA_BOOTSTRAP_SERVERS=localhost:9092\n```\n\n#### Windows (Command Prompt)\n```cmd\nset SPRING_KAFKA_BOOTSTRAP_SERVERS=localhost:9092\n```\n\n#### Windows (PowerShell)\n```powershell\n$env:SPRING_KAFKA_BOOTSTRAP_SERVERS=\"localhost:9092\"\n```\n\n## Building the Project\n\n```bash\nmvn clean install\n```\n\n## Running Tests\n\n```bash\nmvn clean test\n```\n\n## Delivery Modes\n\n### At-most-once Delivery\n\n- Messages may be lost but will never be delivered more than once\n- No acknowledgment required from brokers\n- No retries on failure\n- Best for scenarios where message loss is acceptable\n\n### At-least-once Delivery\n\n- Messages will be delivered at least once\n- Acknowledgment required from all replicas\n- Retries on failure\n- May result in duplicate messages\n- Best for scenarios where duplicates are acceptable but message loss is not\n\n### Exactly-once Delivery\n\n- Messages will be delivered exactly once\n- Uses idempotent producer and transaction management\n- No duplicates and no message loss\n- Best for scenarios requiring strict message delivery guarantees\n\n## Configuration\n\nThe `application.yml` file contains detailed configuration for each delivery mode:\n\n```yaml\nspring:\n  kafka:\n    bootstrap-servers: localhost:9092\n    producer:\n      # At-most-once configuration\n      at-most-once:\n        acks: 0\n        retries: 0\n      \n      # At-least-once configuration\n      at-least-once:\n        acks: all\n        retries: 3\n      \n      # Exactly-once configuration\n      exactly-once:\n        acks: all\n        enable-idempotence: true\n        transaction-id-prefix: exactly-once-\n```\n\n## Testing\n\nThe project includes unit tests for each producer implementation:\n- `testAtMostOnceProducer()`\n- `testAtLeastOnceProducer()`\n- `testExactlyOnceProducer()`\n- `testAtLeastOnceProducerRetry()`\n\nTests use Mockito to mock the KafkaTemplate and verify producer behavior. \n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\nPlease make sure to update tests as appropriate and follow the existing code style.\n\n## Running Kafka Locally\n\n### Single Node Setup\n\nFor local development, you can run a single Kafka broker using Docker:\n\n```bash\ndocker run -d \\\n  --name kafka \\\n  -p 9092:9092 \\\n  -e KAFKA_BROKER_ID=1 \\\n  -e KAFKA_LISTENERS=PLAINTEXT://:9092 \\\n  -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \\\n  -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \\\n  -e KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0 \\\n  -e KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1 \\\n  -e KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 \\\n  -e KAFKA_NODE_ID=0 \\\n  -e KAFKA_PROCESS_ROLES=controller,broker \\\n  -e KAFKA_CONTROLLER_QUORUM_VOTERS=0@kafka:9093 \\\n  -e KAFKA_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \\\n  -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \\\n  -e KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER \\\n  -e KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT \\\n  -e KAFKA_AUTO_CREATE_TOPICS_ENABLE=true \\\n  confluentinc/cp-kafka:7.5.1\n```\n\nThis setup:\n- Uses KRaft (Kafka Raft metadata mode) instead of Zookeeper\n- Exposes port 9092 for client connections\n- Enables auto topic creation\n- Configures the broker for local development\n- Uses the Confluent Kafka image\n\n### Cluster Setup\n\nA Docker Compose setup for running a Kafka cluster locally is available at [kafka-cluster-docker-compose](https://github.com/luismr/kafka-cluster-docker-compose). This setup includes:\n- Multiple Kafka brokers using KRaft (Kafka Raft metadata mode)\n- Network configuration for local development\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluismr%2Fkafka-springboot-blueprint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluismr%2Fkafka-springboot-blueprint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluismr%2Fkafka-springboot-blueprint/lists"}