{"id":23662798,"url":"https://github.com/cassiomolin/microservices-springboot","last_synced_at":"2026-03-14T07:07:46.903Z","repository":{"id":269002513,"uuid":"113579797","full_name":"cassiomolin/microservices-springboot","owner":"cassiomolin","description":"Example of microservices application with Spring Boot, Zuul, Eureka, MongoDB and RabbitMQ.","archived":false,"fork":false,"pushed_at":"2019-09-15T16:18:10.000Z","size":490,"stargazers_count":79,"open_issues_count":4,"forks_count":61,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T21:51:18.500Z","etag":null,"topics":["eureka","jackson","java","jersey","mongodb","rest","spring","springboot","zuul"],"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/cassiomolin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-12-08T13:55:06.000Z","updated_at":"2025-03-12T14:52:16.000Z","dependencies_parsed_at":"2024-12-20T08:49:17.243Z","dependency_job_id":"fe2abb10-b21d-4c73-8e7a-d13f887f1ae3","html_url":"https://github.com/cassiomolin/microservices-springboot","commit_stats":null,"previous_names":["cassiomolin/microservices-springboot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cassiomolin/microservices-springboot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cassiomolin%2Fmicroservices-springboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cassiomolin%2Fmicroservices-springboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cassiomolin%2Fmicroservices-springboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cassiomolin%2Fmicroservices-springboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cassiomolin","download_url":"https://codeload.github.com/cassiomolin/microservices-springboot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cassiomolin%2Fmicroservices-springboot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273162225,"owners_count":25056428,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"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":["eureka","jackson","java","jersey","mongodb","rest","spring","springboot","zuul"],"created_at":"2024-12-29T05:14:03.448Z","updated_at":"2026-03-14T07:07:46.859Z","avatar_url":"https://github.com/cassiomolin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample microservices application with Spring Boot, Zuul, Eureka, MongoDB and RabbitMQ\n\n[![Build Status](https://travis-ci.org/cassiomolin/microservices-springboot.svg?branch=master)](https://travis-ci.org/cassiomolin/microservices-springboot)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/cassiomolin/microservices-springboot/master/LICENSE.txt)\n\nSample microservices application for managing products and shopping lists using:\n\n- **Spring Boot:** Framework for creating standalone Java applications.\n- **Jersey:** JAX-RS reference implementation for creating RESTful web services in Java.\n- **Jackson:** JSON parser for Java.\n- **MapStruct:** Framework for mapping objects in Java.\n- **Netflix Zuul:** API gateway.\n- **Netflix Eureka:** Service discovery.\n- **RabbitMQ:** Message broker.\n- **MongoDB:** NoSQL database based on documents.\n\nThis application consists of four different services:\n\n- **Product service:** Provides API for managing products. By default it runs on port `8001`.\n- **Shopping list service:** Provides API for managing shopping lists. By default it runs on port `8002`.\n- **Service discovery:** Netflix Eureka service that discovers and registers other service instances. By default it runs on port `8761`.\n- **API gateway:** Netflix Zuul API gateway that sits on the top of the product and shopping list services, providing a gateway for those services. By default it runs on port `8765`.\n\nSee the diagram below:\n\n\u003c!-- Hack to center the image in GitHub --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"misc/architecture-diagram.png\" alt=\"Architecture diagram\" width=\"65%\"/\u003e\n\u003c/p\u003e\n\n## External services\n\nThis application depends on external services that must be up and running before attempting to run the application:\n\n### MongoDB\n\nShopping and product services use MongoDB for persistence, but different databases are used for each service.\n\nBefore running the application, ensure that you have a MongoDB instance running on `localhost` port `27017` (default port). The `product` and `shopping-list` databases will be created by the application if they don't exist.\n\n### RabbitMQ\n\nRabbitMQ is used as message broker for communication between the services. When a product is deleted, a message is produced by the product service. This message contains details about the product that has been deleted. The shopping list service consumes the message and removes the deleted product from the shopping lists.\n\nBefore running the application, ensure that a RabbitMQ instance is running on `localhost` port `5672` (default port).\n\n## Building and running this application\n\nTo build and run this application, follow these steps:\n\n1. Open a command line window or terminal.\n1. Navigate to the root directory of the project, where the `pom.xml` resides.\n1. Compile the project: `mvn clean compile`.\n1. Package the application: `mvn package`.\n1. Change into the `target` directory of the `dist` module: `cd dist/target`.\n1. You should see a folder with the following or a similar name: `microservices-1.0`. Change into this folder: `cd microservices-1.0`.\n1. Start the services as indicated below (the order doesn't matter).\n\n### Running the service discovery application\n\n1. Open a command line window or terminal.\n1. Start the `service-discovery` application: `java -jar service-discovery-1.0.jar`.\n1. A Netflix Eureka console will be available at `http://localhost:8761`.\n\n### Running the product service application\n\n1. Open a command line window or terminal.\n1. Start the `product-service` application: `java -jar product-service-1.0.jar`.\n1. This service will start on the port `8001` and it will automatically register itself in the service discovery. Check the Eureka console.\n\n### Running the shopping list service application\n\n1. Open a command line window or terminal.\n1. Start the `shopping-list-service` application: `java -jar shopping-list-service-1.0.jar`.\n1. This service will start on the port `8002` and it will automatically register itself in the service discovery. Check the Eureka console.\n\n### Running the API gateway application\n\n1. Open a command line window or terminal.\n1. Start the `api-gateway` application: `java -jar api-gateway-1.0.jar`.\n\n### Running extra instances (optional)\n\nIf you want to, you can run extra instances of `product-service` and `shopping-list-service` applications, just use a different port: `java -DPORT=8003 -jar product-service-1.0.jar`. New instances will automatically register themselves in the service discovery.\n\nRequests coming from the `api-gateway` service will be balanced between the instances.\n\n## REST API overview\n\nThe application provides a REST API for managing tasks. See the [curl][] scripts below with the supported operations:\n\n### Get all products\n\n```bash\ncurl -X GET \\\n  'http://localhost:8765/api/products' \\\n  -H 'Accept: application/json'\n```\n\n### Create a product\n\n```bash\ncurl -X POST \\\n  'http://localhost:8765/api/products' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n  \"name\": \"Cake\"\n}'\n```\n\n### Get a product by id\n\n```bash\ncurl -X GET \\\n  'http://localhost:8765/api/products/{product-id}' \\\n  -H 'Accept: application/json'\n```\n\n### Update a product\n\n```bash\ncurl -X POST \\\n  'http://localhost:8765/api/products/{product-id}' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n  \"name\": \"Chocolate cake\"\n}'\n```\n\n### Delete a product by id\n\n```bash\ncurl -X DELETE \\\n  'http://localhost:8765/api/products/{product-id}'\n```\n\n### Get all shopping lists\n\n```bash\ncurl -X GET \\\n  'http://localhost:8765/api/shopping-lists' \\\n  -H 'Accept: application/json'\n```\n\n### Create a shopping list\n\n```bash\ncurl -X POST \\\n  'http://localhost:8765/api/shopping-lists' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n  \"name\": \"My shopping list\",\n  \"items\": [\n    {\n      \"id\": \"{product-id}\"\n    },\n    {\n      \"id\": \"{product-id}\"\n    },\n    ...\n  ]\n}'\n```\n\n### Get a shopping list by id\n\n```bash\ncurl -X GET \\\n  'http://localhost:8765/api/shopping-lists/{shopping-list-id}' \\\n  -H 'Accept: application/json'\n```\n\n### Update a shopping list\n\n```bash\ncurl -X PUT \\\n  'http://localhost:8765/api/shopping-lists/{shopping-list-id}' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n  \"name\": \"Birthday party\",\n  \"items\": [\n    {\n      \"id\": \"{product-id}\"\n    },\n    {\n      \"id\": \"{product-id}\"\n    },\n    ...\n  ]\n}'\n```\n\n### Delete a shopping list by id\n\n```bash\ncurl -X DELETE \\\n  'http://localhost:8765/api/shopping-lists/{shopping-list-id}'\n```\n\n## Targeting the REST API with Postman\n\nAlternatively to [curl][], you can use [Postman][] to target the REST API. Check the Postman [collection](misc/microservices-springboot.postman_collection.json) and the [environment variables](misc/microservices-springboot.postman_environment.json) as well.\n\n[Postman]: https://www.getpostman.com/\n[curl]: https://curl.haxx.se/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcassiomolin%2Fmicroservices-springboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcassiomolin%2Fmicroservices-springboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcassiomolin%2Fmicroservices-springboot/lists"}