{"id":15960617,"url":"https://github.com/devzwy/springclouddemo","last_synced_at":"2025-04-04T11:34:25.719Z","repository":{"id":112155782,"uuid":"259216693","full_name":"devzwy/SpringCloudDemo","owner":"devzwy","description":"🔥🔥🔥🔥🔥🔥SpringCloud常用组件的使用Demo","archived":false,"fork":false,"pushed_at":"2020-04-27T06:37:13.000Z","size":2211,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T21:27:57.915Z","etag":null,"topics":["eureka","eureka-client","eureka-server","hystrix","ribbon","springcloud","springcloud-demo","springcloud-hystrix","springcloud-ribbon","springcloudeureka"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/devzwy.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,"publiccode":null,"codemeta":null}},"created_at":"2020-04-27T05:42:26.000Z","updated_at":"2020-04-27T06:40:07.000Z","dependencies_parsed_at":"2023-08-01T08:47:20.103Z","dependency_job_id":null,"html_url":"https://github.com/devzwy/SpringCloudDemo","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/devzwy%2FSpringCloudDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzwy%2FSpringCloudDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzwy%2FSpringCloudDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devzwy%2FSpringCloudDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devzwy","download_url":"https://codeload.github.com/devzwy/SpringCloudDemo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247171901,"owners_count":20895733,"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":["eureka","eureka-client","eureka-server","hystrix","ribbon","springcloud","springcloud-demo","springcloud-hystrix","springcloud-ribbon","springcloudeureka"],"created_at":"2024-10-07T15:20:52.991Z","updated_at":"2025-04-04T11:34:25.701Z","avatar_url":"https://github.com/devzwy.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpringCloud使用到的相关组件以及端口等说明\n___\n\n EurekaServer：服务注册中心 端口使用8000  \n EurekaClient：微服务客户端(内容提供者) 端口分别使用9000、9001、9002、9003，在Idea Configuration中自行配置  \n PublicApi：消费端+Hystrix（熔断器）+Zuul(路由网关以及全局拦截)  外网调用路径 端口80 \n#### 1. Eureka  \n服务治理,服务注册中心  \n#### 2.Hystrix\n熔断器\n#### 3.Zuul\n路由网关以及全局拦截  \n\n### 项目启动流程：\n首先启动注册中心:`EurekaServer`启动后访问`localhost:8000`看到如下页面  \n\n![image1](https://github.com/devzwy/SpringCloudDemo/blob/master/images/1.png)    \n\n随后启动微服务`EurekaClient()`,至少启动一个端口,启动后可在以上页面发现注册成功的微服务    \n\n![image2](https://github.com/devzwy/SpringCloudDemo/blob/master/images/2.png)    \n\n最后启动外部调用端微服务`PublicApi`,访问:`localhost/getUser`,数据会通过不同的端口返回，\n如果其中有服务掉线后会通过熔断器返回预先定义好的数据，并根据熔断器配置的策略选择重连/remove机制，remove后该端口将不会被使用 \n  \n#### 以下图片来自测试熔断器过程图片，假设开启两个服务端口9000,9001\n![image3](https://github.com/devzwy/SpringCloudDemo/blob/master/images/3.png)     \n\npostMan正常访问，从9000和9001不同端口返回，负载均衡没问题。     \n\n![image4](https://github.com/devzwy/SpringCloudDemo/blob/master/images/4.png)  \n\n![image5](https://github.com/devzwy/SpringCloudDemo/blob/master/images/5.png)    \n \n关闭其中的9000端口    \n\n![image6](https://github.com/devzwy/SpringCloudDemo/blob/master/images/6.png)     \n\n再使用Postman访问，当负载均衡分配到9000端口时，熔断器会工作，如：    \n\n![image7](https://github.com/devzwy/SpringCloudDemo/blob/master/images/7.png)  \n \n间隔10s后再次访问(一段时间内访问如果再次被分配到9000，还是会返回失败信息，详见熔断器介绍),负载均衡将不会再分发到9000端口    \n\n![image8](https://github.com/devzwy/SpringCloudDemo/blob/master/images/8.png)     \n \n再次启动9000端口    \n\n![imag9](https://github.com/devzwy/SpringCloudDemo/blob/master/images/9.png)   \n  \n间隔一段时间后，负载均衡又可以分配到9000端口了。自动重连成功。    \n\n![image10](https://github.com/devzwy/SpringCloudDemo/blob/master/images/10.png)  \n   \n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevzwy%2Fspringclouddemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevzwy%2Fspringclouddemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevzwy%2Fspringclouddemo/lists"}