{"id":22191647,"url":"https://github.com/leosimoes/java-spring-kafka-hello","last_synced_at":"2026-05-04T04:31:52.206Z","repository":{"id":233289530,"uuid":"786460759","full_name":"leosimoes/Java-Spring-Kafka-Hello","owner":"leosimoes","description":"Project in Java with Spring, Gradle and Kafka to create a topic producing and consuming application.","archived":false,"fork":false,"pushed_at":"2024-04-14T19:00:58.000Z","size":943,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T20:43:40.343Z","etag":null,"topics":["java","kafka","messaging","spring"],"latest_commit_sha":null,"homepage":"","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/leosimoes.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}},"created_at":"2024-04-14T14:35:01.000Z","updated_at":"2024-05-29T20:36:49.000Z","dependencies_parsed_at":"2024-04-15T14:50:03.248Z","dependency_job_id":null,"html_url":"https://github.com/leosimoes/Java-Spring-Kafka-Hello","commit_stats":null,"previous_names":["leosimoes/java-spring-kafka-hello"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leosimoes/Java-Spring-Kafka-Hello","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FJava-Spring-Kafka-Hello","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FJava-Spring-Kafka-Hello/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FJava-Spring-Kafka-Hello/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FJava-Spring-Kafka-Hello/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leosimoes","download_url":"https://codeload.github.com/leosimoes/Java-Spring-Kafka-Hello/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FJava-Spring-Kafka-Hello/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32595077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","kafka","messaging","spring"],"created_at":"2024-12-02T12:17:04.571Z","updated_at":"2026-05-04T04:31:52.190Z","avatar_url":"https://github.com/leosimoes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Kafka - Hello\nProject in Java with Spring, Gradle and Kafka to create a topic producing and consuming application.\n\n![Img-04-UML-Classes](images/Img-04-UML-Classes.png)\n\n\n## Steps\nThe steps of project implementation:\n\n1. Create project (in IntelliJ) with:\n- Java language (17);\n- Spring Framework (6.2.3);\n- Dependencies: Web, Kafka, DevTools.\n\n![Img-01-IntelliJ](images/Img-01-IntelliJ.png)\n\n2. Configure and run Kafka on local machine with Docker:\n- Create the `docker-compose.yml` file:\n\n```yml\n version: '2'\nservices:\n  zookeeper:\n    image: confluentinc/cp-zookeeper:7.4.4\n    environment:\n      ZOOKEEPER_CLIENT_PORT: 2181\n      ZOOKEEPER_TICK_TIME: 2000\n    ports:\n      - 22181:2181\n  \n  kafka:\n    image: confluentinc/cp-kafka:7.4.4\n    depends_on:\n      - zookeeper\n    ports:\n      - 29092:29092\n    environment:\n      KAFKA_BROKER_ID: 1\n      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181\n      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092\n      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT\n      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT\n      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1\n```\n\n- In the terminal run `docker-compose up`;\n\n![Img-02-Terminal-dockerup](images/Img-02-Terminal-dockerup.png)\n\n![Img-03-DockerDesktop](images/Img-03-DockerDesktop.png)\n\n- Change `application.properties` to find Kafka:\n\n```properties\nspring.kafka.bootstrap-servers=localhost:29092\n```\n\n3. Create `HelloProducerService` class:\n- annotated with `@Service`;\n- with a `KafkaTemplate\u003cString, String\u003e kafkaTemplate` attribute;\n- with a constructor with an argument;\n- with a `void sendMessage(String message)` method;\n\n4. Create `HelloConsumerService` class:\n- annotated with `@Service`;\n- with a method `@KafkaListener(topics = \"hello-topic\", groupId = \"group-1\") public void receiveMessage(String message)`;\n\n5. Create `HelloController` class:\n- annotated with `@RestController` and `@RequestMapping(\"/kafka\")`;\n- with a `HelloProducerService service` attribute;\n- with a constructor with one argument and annotated with `@Autowired`;\n- with a method `@GetMapping(\"/hello/{name}\") public String hello(@PathVariable(\"name\") String name)`;\n\n6. Test application with POSTMAN `localhost:8080/kafka/hello/leo`.\n\n![Img-05-Postman-Hello-leo](images/Img-05-Postman-Hello-leo.png)\n\n\n## References\nSpring for Apache Kafka - Quick Tour:\nhttps://docs.spring.io/spring-kafka/reference/quick-tour.html\n\nBaeldung - Intro to Apache Kafka with Spring:\nhttps://www.baeldung.com/spring-kafka\n\nIntrodução à Mensageria com Spring e Kafka - Giuliana Bezerra:\nhttps://www.youtube.com/watch?v=97TF2xZgAhU | https://github.com/giuliana-bezerra/messaging-springboot","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleosimoes%2Fjava-spring-kafka-hello","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleosimoes%2Fjava-spring-kafka-hello","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleosimoes%2Fjava-spring-kafka-hello/lists"}