{"id":13753013,"url":"https://github.com/sherxon/microservice-architecture","last_synced_at":"2025-05-09T20:34:42.019Z","repository":{"id":60675240,"uuid":"98063632","full_name":"sherxon/microservice-architecture","owner":"sherxon","description":"POC: Microservice Architecture Pattern using Spring Boot and netflix applications: It includes API Gateway, Service Discovery and Registry, Circuit Breaker, Load Balancer and Centralized Config Management","archived":false,"fork":false,"pushed_at":"2017-08-07T03:50:31.000Z","size":42,"stargazers_count":35,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-16T05:32:33.478Z","etag":null,"topics":["api-gateway","configuration-management","eureka-server","microservice","ribbon","service-discovery","spring-boot","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/sherxon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-22T23:35:56.000Z","updated_at":"2024-03-31T14:19:44.000Z","dependencies_parsed_at":"2022-10-03T02:00:18.161Z","dependency_job_id":null,"html_url":"https://github.com/sherxon/microservice-architecture","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherxon%2Fmicroservice-architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherxon%2Fmicroservice-architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherxon%2Fmicroservice-architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sherxon%2Fmicroservice-architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sherxon","download_url":"https://codeload.github.com/sherxon/microservice-architecture/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253321812,"owners_count":21890470,"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":["api-gateway","configuration-management","eureka-server","microservice","ribbon","service-discovery","spring-boot","zuul"],"created_at":"2024-08-03T09:01:14.508Z","updated_at":"2025-05-09T20:34:39.925Z","avatar_url":"https://github.com/sherxon.png","language":"Java","funding_links":[],"categories":["zuul"],"sub_categories":[],"readme":"##  POC: Microservice Architecture Pattern using Spring Boot and netflix technologies and helpful hints\n\nThis project can be used as showcase or Proof of Concept to build and manage micro services using Spring Boot.\n\nIt includes:    \n\n[Config Server]() =\u003e Spring Cloud Config  \n[API GateWay]() =\u003e Zuul by Netflix  \n[Service Registry]() =\u003e Eureka by Netflix  \n[Sample Spring Boot Application]()\n\n  If you are not familiar with micro service architecture pattern, I recommend 3 min reading [Microservice Architecture](http://microservices.io/patterns/microservices.html)   \n  first by Chris Richardson. \n  \n### General Overview\n\nAll micro services are spring boot applications with dependencies managed by maven. Each Service has bootstrap.yml \nfile which stores minimum required configuration for each service.  \n\nI have added all above mentioned micro services into one parent project just to make it easy to manage in one place  \nas it is just a POC project, without much business logic abd heavy requirements. You can still run each \nmicro service independently.\n\nThis is [Config First Bootstrap](https://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#config-first-bootstrap), so you \nshould run Config Server first and Eureka Server second then Api Gateway and other micro services. \nYou may see runtime exceptions thrown by Config Server when you run it until Eureka Server runs and Config server register itself.\n\n#### Helpful Hints\n* Use `.yml` files instead of `.properties`, so you can write more than one profile configurations for each service with `---` \nbetween them in one yml file and of course shorter code.     \n* Keep all your source code always in certain package, not in source root to make it scanable by Spring DI   \n\n### Config Server OverView \n\n**Config Server** is used to store configurations of all micro services in one centralized place. You can keep and change   \nconfiguration of any micro service such as database credentials and network location in externalized place and restart the service \nto pull new configuration. To learn more about it check this out [Externalized configuration](http://microservices.io/patterns/externalized-configuration.html) \n\nTo implement externalized configuration pattern I used [Spring Cloud Config Server](https://cloud.spring.io/spring-cloud-config/spring-cloud-config.html) and  config clients. To make \nany spring boot application a config server you can just add one maven starter dependency and `@EnableEurekaServer` on configuration class. \nSpring cloud config server serves clients over rest api. Clients need to add spring-cloud-config-client dependency and \nconfig server or eureka server ( if you want config server to be discovered by eureka) location in bootstrap.yml \n \nOnce we run our config server at default 8888 port, we can get all configs using following rules in json format.  \n \n**application** is the name of service defined by `spring.application.name` (or `spring.cloud.config.name`) in config file.  \n**profile** is the name of profiles set by `spring.profiles.active` on the client side , separated by comma  \n**label** is the label name to pull remote config files. if remote config location is git, the label is _master_ by default.   \n \n`/{application}/{profile}[/{label}]` such as http://localhost:8888/api-gateway/default  \n`/{application}-{profile}.yml`   \n`/{label}/{application}-{profile}.yml`  \n`/{application}-{profile}.properties`  \n`/{label}/{application}-{profile}.properties`  \n\n##### Attention\n\n1. If you want to store remote config in filesystem, \nbesides providing file path: `spring.cloud.config.server.native.searchLocations=file:{path}`, \nyou should also use `spring.profiles.active=native` profile.  \n2. You can just add `spring.cloud.config.server.bootstrap=true` to bootstrap.yml of config server to tell config server to get \nits configuration from remote file or repository on git.  \n3. Use `@RefreshScope` annotation in each client of config server, including config server itself, if you want changed configurations take an \naffect by sending post request  `/refresh` endpoints. \nfrom remote location.  \n4. Config Server does not cache configurations, it reads from remote location (git or filesystem) for each request. \n5. \n\n\n\n### Service Registry Overview:\n  \n**Service Registry** is a service that keeps track of all other micro service instances, their location and health. All micro \nservices register themselves with their information to Service Registry at startup and is deregistered if Service Registry \ncannot reach at certain point. Client Services such as Api Gateway ask Service Registry for location of available micro service\ninstance. Eureka is used in this project as an implementation of Service Registry.  \n\n\u003c!---\nenable self preservation\n\nHysterix\nhttps://github.com/Netflix/Hystrix/wiki/Configuration\n\n--\u003e\n#### Attention\n* `@EnableEurekaClient`==`@EnableDiscoveryClient` makes spring boot app both instance (i.e. it registers itself and change `eureka.instance.*`) and a client\n (i.e. it can query the registry to locate other services and change `eureka.client.*` ).    \n* if you want to enable `eureka.client.healthcheck.enabled=true`, use application.properties for this config, otherwise you \ncan see UNKNOWN status on Eureka dashboard. \n\nI dont have to write a lot about Eureka Server, you can read this awesome [Spring Cloud Netflix Eureka - The Hidden Manual](http://blog.abhijitsarkar.org/technical/netflix-eureka/) \nblog by Abhijit Sarkar and get thorough understanding about Eureka Server.   \n\nIn this project, Eureka server loads its configuration from Config Server and at the same time Config Server is eureka client.\n\n \n\n### Api Gateway Overview \n\n**Api Gateway (Zuul)** is the implementation of Backend for Front-End pattern. Main motive to use Api Gateway is to have one edge service \nfor clients and still manage a number of service instances and their locations (host+port) which change dynamically. \nTo learn more about this, check this out [Pattern: API Gateway](http://microservices.io/patterns/apigateway.html)\n\n\n\n#### Disclaimer\nThis project is Shareware and distributed under GSL(General Sharewire Licence), which means you can do whatever you want \nwith it once you share it with at least one person :). Most of ideas and \"hints\" are just my opinions\nand solutions to problems I have faced up. Thanks to stackoverflow and netflix community.  \n    \nIf you think improvement or a change is needed in any part of the project, feel to contribute !      \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsherxon%2Fmicroservice-architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsherxon%2Fmicroservice-architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsherxon%2Fmicroservice-architecture/lists"}