0%

在SpringCloud中了提供了基于Netflix Zuul实现的API网关组件Spring Cloud Zuul。

SpringCloud Zuul可以通过与SpringCloud Eureka进行整合,将自身注册为Eureka服务治理下的应用,同时从Eureka中获得了所有其他微服务的实例信息。这样的设计非常巧妙地将服务治理体系中维护的实例信息利用起来,使得将维护服务实例的工作交给了服务治理框架自动完成,不再需要人工介入。

阅读全文 »

pom.xml

1
2
3
4
5
6
7
8
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

application.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
server:
port: 7003

eureka:
instance:
hostname: localhost
client:
serviceUrl:
defaultZone: http://localhost:7001/eureka/ #注册中心的地址

spring:
application:
name: service-producer #服务的名字

启动类添加注解**@EnableDiscoveryClient**

阅读全文 »

断路器模式源于Martin Fowler的Circuit Breaker一文。“断路器”本身是一种开关装置,用于在电路上保护线路过载,当线路中有电器发生短路时,“断路器”能够及时的切断故障电路,防止发生过载、发热、甚至起火等严重后果。

阅读全文 »