Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbdd64bd

Browse files
committed
update
1 parentbc92577 commitbdd64bd

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

‎SUMMARY.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*[实现服务的注册与发现](docs/register-discover/eureka-in-action.md)(完)
1818
*[微服务的消费](docs/comsumer/comsumer.md)
1919
*[微服务的消费模式](docs/comsumer/comsumer-patterns.md)
20-
*[常见微服务的消费者](docs/comsumer/comsumer-cases.md)(完)
21-
*[实现服务的消费者](docs/comsumer/comsumer-in-action.md)
22-
*[实现服务的负载均衡及高可用](docs/comsumer/ribbon-in-action.md)
20+
*[常见微服务的消费者](docs/comsumer/comsumer-cases.md)
21+
*[实现服务的消费者](docs/comsumer/comsumer-in-action.md)(完)
22+
*[实现服务的负载均衡及高可用](docs/comsumer/ribbon-in-action.md)(完)
2323
*[API 网关](docs/api-gateway/api-gateway.md)
2424
*[API 网关的意义](docs/api-gateway/api-gateway-meaning.md)
2525
*[常见 API 网关的实现方式](docs/api-gateway/api-gateway-patterns.md)

‎docs/comsumer/ribbon-in-action.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
#实现服务的负载均衡及高可用
22

3+
如果你自己观察 Feign 依赖,可以看到,Feign 是依赖了 Ribbon的。
4+
5+
```xml
6+
<dependency>
7+
<groupId>org.springframework.cloud</groupId>
8+
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
9+
</dependency>
10+
```
11+
12+
有兴趣的朋友,可以自行查看依赖信息:<https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-starter-netflix/spring-cloud-starter-openfeign/pom.xml>
13+
14+
##客户端负载均衡器——Ribbon
15+
16+
Ribbon 是一个客户端负载平衡器,它可以很好地控制HTTP和TCP客户端的行为。 Feign 已经使用 Ribbon,所以如果你使用`@FeignClient`,就已经启用了客户端负载均衡功能。
17+
18+
Ribbon 的一个中心概念就是命名客户端(named clien)。 每个负载平衡器都是组合的组件的一部分,它们一起工作以根据需要联系远程服务器,并且集合具有您将其作为应用程序开发人员(例如使用`@FeignClient`注解)的名称。 Spring Cloud使用RibbonClientConfiguration为每个命名的客户端根据需要创建一个新的集合作为ApplicationContext。 这包含(其中包括)一个ILoadBalancer,一个RestClient和一个ServerListFilter。
19+
20+
##实现高可用
21+
22+
将我们需要访问的服务(比如,“micro-weather-eureka-client”),启动为多个示例。当客户端需要访问“micro-weather-eureka-client”时,会自行去选择其中任意一个服务实例来访问,这样,即便其中的某个服务实例不可用,也不会影响整个服务功能。
23+
24+
这样就实现了服务的高可用。

‎samples/micro-weather-feign/src/test/java/com/waylau/spring/cloud/service/HelloClientTest.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ public class HelloClientTest {
2121

2222
@Test
2323
publicvoidtestHello() {
24-
2524
Stringhello =helloClient.getHello();
2625
System.out.println(hello);
27-
hello =helloClient.getHello();
28-
System.out.println(hello);
2926
}
3027

3128
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp