这个是用来发现服务链的,需要本地运行jar包
0环境
需要文件zipkin-server-2.12.9-exec.jar
,然后将其编译 java -jar zipkin-server-2.12.9-exec.jar
这个时候就可以登录 http://localhost:9411/zipkin/
查看管理界面了
1搭建
这里直接修改最普通的8001和80,当然还用到了7001
服务
1pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
2yml
spring:
zipkin:
base-url: http://localhost:9411
sleuth:
sampler:
probability: 1
3业务类controller
@GetMapping("/payment/zipkin")
public String paymentZipkin()
{
return "hi ,i'am paymentzipkin server fall back,welcome to atguigu,O(∩_∩)O哈哈~";
}
消费
pom和yml都一样,因为这里是链路,没有消费提供的关系
3业务类controller
@GetMapping("/consumer/payment/zipkin")
public String paymentZipkin()
{
String result = restTemplate.getForObject("http://localhost:8001"+"/payment/zipkin/", String.class);
return result;
}
//调用服务
2查看结果
发送请求:http://localhost/consumer/payment/zipkin
(但是这里我自己出错了,显示500错误,No instances available for localhost)
然后在http://localhost:9411/zipkin/就看得到效果了,带劲