{"id":18048071,"url":"https://github.com/ivangfr/spring-cloud-stream-event-routing-cloudevents","last_synced_at":"2026-03-27T02:10:53.857Z","repository":{"id":111328492,"uuid":"402184751","full_name":"ivangfr/spring-cloud-stream-event-routing-cloudevents","owner":"ivangfr","description":"The goal of this project is to play with Spring Cloud Stream Event Routing and CloudEvents. For it, we will implement a producer and consumer of news \u0026 alert events.","archived":false,"fork":false,"pushed_at":"2025-12-19T11:39:29.000Z","size":1818,"stargazers_count":25,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-22T04:26:18.432Z","etag":null,"topics":["cloudevents","event-routing","graalvm","java","kafdrop","kafka","native","spring-boot","spring-cloud-stream","spring-webflux"],"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/ivangfr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":"ivangfr"}},"created_at":"2021-09-01T19:49:39.000Z","updated_at":"2025-12-19T11:39:33.000Z","dependencies_parsed_at":"2023-11-13T22:30:50.033Z","dependency_job_id":"aecfb46b-976f-4e09-ad56-df7954399e95","html_url":"https://github.com/ivangfr/spring-cloud-stream-event-routing-cloudevents","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ivangfr/spring-cloud-stream-event-routing-cloudevents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspring-cloud-stream-event-routing-cloudevents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspring-cloud-stream-event-routing-cloudevents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspring-cloud-stream-event-routing-cloudevents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspring-cloud-stream-event-routing-cloudevents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivangfr","download_url":"https://codeload.github.com/ivangfr/spring-cloud-stream-event-routing-cloudevents/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspring-cloud-stream-event-routing-cloudevents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31009397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T01:56:05.093Z","status":"online","status_checked_at":"2026-03-27T02:00:08.055Z","response_time":164,"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":["cloudevents","event-routing","graalvm","java","kafdrop","kafka","native","spring-boot","spring-cloud-stream","spring-webflux"],"created_at":"2024-10-30T20:11:14.387Z","updated_at":"2026-03-27T02:10:53.846Z","avatar_url":"https://github.com/ivangfr.png","language":"Java","funding_links":["https://github.com/sponsors/ivangfr"],"categories":[],"sub_categories":[],"readme":"# spring-cloud-stream-event-routing-cloudevents\n\nThe goal of this project is to play with [`Spring Cloud Stream Event Routing`](https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream.html#_event_routing) and [`CloudEvents`](https://cloudevents.io/). For it, we will implement a producer and consumer of `news` \u0026 `alert` events.\n\n## Proof-of-Concepts \u0026 Articles\n\nOn [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-Concepts (PoCs) and articles. You can easily search for the technology you are interested in by using the filter. Who knows, perhaps I have already implemented a PoC or written an article about what you are looking for.\n\n## Additional Readings\n\n- \\[**Medium**\\] [**How to Route CloudEvents messages with Spring Cloud Stream**](https://medium.com/@ivangfr/how-to-route-cloudevents-messages-with-spring-cloud-stream-3cf7a5ab4e17)\n- \\[**Medium**\\] [**Implementing a Kafka Producer and Consumer using Spring Cloud Stream**](https://medium.com/@ivangfr/implementing-a-kafka-producer-and-consumer-using-spring-cloud-stream-d4b9a6a9eab1)\n- \\[**Medium**\\] [**Implementing Unit Tests for a Kafka Producer and Consumer that uses Spring Cloud Stream**](https://medium.com/@ivangfr/implementing-unit-tests-for-a-kafka-producer-and-consumer-that-uses-spring-cloud-stream-f7a98a89fcf2)\n- \\[**Medium**\\] [**Implementing End-to-End testing for a Kafka Producer and Consumer that uses Spring Cloud Stream**](https://medium.com/@ivangfr/implementing-end-to-end-testing-for-a-kafka-producer-and-consumer-that-uses-spring-cloud-stream-fbf5e666899e)\n- \\[**Medium**\\] [**Configuring Distributed Tracing with Zipkin in a Kafka Producer and Consumer that uses Spring Cloud Stream**](https://medium.com/@ivangfr/configuring-distributed-tracing-with-zipkin-in-a-kafka-producer-and-consumer-that-uses-spring-cloud-9f1e55468b9e)\n- \\[**Medium**\\] [**Using Cloudevents in a Kafka Producer and Consumer that uses Spring Cloud Stream**](https://medium.com/@ivangfr/using-cloudevents-in-a-kafka-producer-and-consumer-that-uses-spring-cloud-stream-9c51670b5566)\n\n## Project Diagram\n\n![project-diagram](documentation/project-diagram.jpeg)\n\n## Applications\n\n- ### producer-service\n\n  [`Spring Boot`](https://docs.spring.io/spring-boot/index.html) application that exposes a REST API to submit `news` \u0026 `alert` events.\n\n  Endpoints\n  ```text\n  POST /api/news/cnn {\"title\":\"...\"}\n  POST /api/news/dw {\"titel\":\"...\"}\n  POST /api/news/rai {\"titolo\":\"...\"}\n  POST /api/alerts/earthquake {\"richterScale\":\"...\", \"epicenterLat\":\"...\", \"epicenterLon\":\"...\"}\n  POST /api/alerts/weather {\"message\":\"...\"}\n  ```\n\n- ### consumer-service\n\n  `Spring Boot` application that consumes the `news` \u0026 `alert` events published by `producer-service`.\n\n## Prerequisites\n\n- [`Java 25`](https://www.oracle.com/java/technologies/downloads/#java25) or higher.\n- A containerization tool (e.g., [`Docker`](https://www.docker.com), [`Podman`](https://podman.io), etc.)\n\n## Start Environment\n\n- Open a terminal and inside the `spring-cloud-stream-event-routing-cloudevents` root folder run:\n  ```bash\n  docker compose up -d\n  ```\n\n- Wait for Docker containers to be up and running. To check it, run:\n  ```bash\n  docker ps -a\n  ```\n\n## Running Applications with Maven\n\n- **producer-service**\n\n  - In a terminal, make sure you are in the `spring-cloud-stream-event-routing-cloudevents` root folder;\n  - Run the command below to start the application:\n    ```bash\n    ./mvnw clean spring-boot:run --projects producer-service\n    ```\n\n- **consumer-service**\n\n  - Open a new terminal and navigate to the `spring-cloud-stream-event-routing-cloudevents` root folder\n  - Run the following command to start the application:\n    ```bash\n    ./mvnw clean spring-boot:run --projects consumer-service\n    ```\n\n## Running Applications as Docker containers\n\n- ### Build Docker Images\n\n  - In a terminal, make sure you are inside the `spring-cloud-stream-event-routing-cloudevents` root folder;\n  - Run the following script to build the Docker images:\n    - JVM\n      ```bash\n      ./build-docker-images.sh\n      ```\n    - Native\n      ```bash\n      ./build-docker-images.sh native\n      ```\n\n- ### Environment Variables\n\n  - **producer-service**\n\n    | Environment Variable | Description                                                             |\n    |----------------------|-------------------------------------------------------------------------|\n    | `KAFKA_HOST`         | Specify host of the `Kafka` message broker to use (default `localhost`) |\n    | `KAFKA_PORT`         | Specify port of the `Kafka` message broker to use (default `29092`)     |\n\n  - **consumer-service**\n\n    | Environment Variable | Description                                                             |\n    |----------------------|-------------------------------------------------------------------------|\n    | `KAFKA_HOST`         | Specify host of the `Kafka` message broker to use (default `localhost`) |\n    | `KAFKA_PORT`         | Specify port of the `Kafka` message broker to use (default `29092`)     |\n\n- ### Run Docker Containers\n\n  - **producer-service**\n    \n    Run the following command in a terminal:\n    ```bash\n    docker run --rm --name producer-service -p 9080:9080 \\\n      -e KAFKA_HOST=kafka -e KAFKA_PORT=9092 \\\n      --network=spring-cloud-stream-event-routing-cloudevents_default \\\n      ivanfranchin/producer-service:1.0.0\n    ```\n\n  - **consumer-service**\n    \n    Open a new terminal and run the following command:\n    ```bash\n    docker run --rm --name consumer-service -p 9081:9081 \\\n      -e KAFKA_HOST=kafka -e KAFKA_PORT=9092 \\\n      --network=spring-cloud-stream-event-routing-cloudevents_default \\\n      ivanfranchin/consumer-service:1.0.0\n    ```\n\n## Playing around\n\nIn a terminal, submit the following POST requests to `producer-service` and check its logs and the `consumer-service` logs\n\n\u003e **Note**: [HTTPie](https://httpie.org/) is being used in the calls below.\n\n- **news**\n  ```bash\n  http :9080/api/news/cnn title=\"NYC subway strike\"\n  http :9080/api/news/dw titel=\"Berliner Untergrundstreik\"\n  http :9080/api/news/rai titolo=\"Sciopero della metropolitana di Roma\"\n  ```\n\n- **alerts**\n  ```bash\n  http :9080/api/alerts/earthquake richterScale=5.5 epicenterLat=37.7840781 epicenterLon=-25.7977037\n  http :9080/api/alerts/weather message=\"Thunderstorm in Berlin\"\n  ```\n\n## Useful links\n\n- **Kafdrop**\n\n  `Kafdrop` can be accessed at http://localhost:9000\n\n## Shutdown\n\n- To stop applications, go to the terminals where they are running and press `Ctrl+C`\n- To stop and remove docker compose containers, network and volumes, go to a terminal and, inside the `spring-cloud-stream-event-routing-cloudevents` root folder, run the following command:\n  ```bash\n  docker compose down -v\n  ```\n\n## Running Test Cases\n\nIn a terminal, make sure you are inside the `spring-cloud-stream-event-routing-cloudevents` root folder:\n\n- **producer-service**\n  ```bash\n  ./mvnw clean test --projects producer-service\n  ```\n\n- **consumer-service**\n  ```bash\n  ./mvnw clean test --projects consumer-service\n  ```\n\n## Cleanup\n\nTo remove the Docker images created by this project, go to a terminal and inside the `spring-cloud-stream-event-routing-cloudevents` root folder, run the following script:\n```bash\n./remove-docker-images.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangfr%2Fspring-cloud-stream-event-routing-cloudevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivangfr%2Fspring-cloud-stream-event-routing-cloudevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangfr%2Fspring-cloud-stream-event-routing-cloudevents/lists"}