改造已有程序
改造cloud-consumer-order8080
pom添加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
yml添加配置
spring:
zipkin:
base-url: http://localhost:9411
sleuth:
sampler:
probability: 1
控制层添加代码
@GetMapping("/consumer/payment/zipkin")
public String paymentZipkin()
{
String result = restTemplate.getForObject("http://localhost:8081"+"/payment/zipkin/", String.class);
return result;
}
改造cloud-consumerzk-order8081
pom添加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
yml添加配置
spring:
zipkin:
base-url: http://localhost:9411
sleuth:
sampler:
probability: 1
控制层添加代码
@GetMapping("/payment/zipkin")
public String paymentZipkin() {
return "hi ,i'am paymentzipkin server fall back,welcome to here, O(∩_∩)O哈哈~";
}
运行
县启动本地的zipkin服务,在启动7001,在启动8080和8081
|