SpringCloud 中 Config、Bus、Stream、Sleuth
文章目录
- 🚏 第十三章 分布式配置中心
- 🚬 一、Config 概述
- 🚬 二、Config 快速入门
- 🚭 config-server:
- 🛹 1、使用gitee创建远程仓库,上传配置文件
- 🛹 2、导入 config-server 依赖
- 🛹 3、搭建 config-server 模块
- 🛹 4、编写配置,设置 gitee 远程仓库地址
- 🛹 5、测试访问远程配置文件
- 🚭 config-client: provider
- 🛹 1、导入 starter-config 依赖
- 🛹 2、配置config server 地址,读取配置文件名称等信息
- 🛹 3、获取配置值
- 🛹 4、启动测试
- 🚭 Config 客户端刷新
- 🛹 1、在 config 客户端引入 actuator 依赖
- 🛹 2、获取配置信息类上,添加 @RefreshScope 注解
- 🛹 3、添加配置
- 🛹 4、使用curl工具发送post请求
- 🚬 三、Config 集成Eureka
- 🚭 config-client配置:
- 🚭 config-server配置:
- 🚏 第十四章 SpringCloud Bus消息总线
- 🚬 一、Bus 概述
- 🚬 二、RabbitMQ(message queue 消息对列)
- 🚬 三、Bus 快速入门-运维
- 🚭 1、分别在 config-server 和 config-client中引入 bus依赖:bus-amqp
- 🚭 2、分别在 config-server 和 config-client中配置 RabbitMQ
- 🛹 server 的配置文件:
- 🛹 client的配置文件 bootstrap.yml
- 🚭 3、在config-server中设置暴露监控断点:bus-refresh
- 🚭 4、启动测试
- 🛹 1、git配置改变
- 🛹 2、往配置中心发请求
- 🛹 3、微服务自动重启
- 🛹 4、访问微服务,发现配置已经改变
- 🚏 第十五章 SpringCloud Stream消息驱动
- 🚬 一、Stream 概述
- 🚭 Stream 组件
- 🚬 二、Stream 消息生产者 stream-producer
- 🚭 消息发送类
- 🚭 调用的controller
- 🚬 三、Stream 消息消费者 stream-consumer
- 🚭 消息接收类
- 🚏 第十六章 SpringCloud Sleuth分布式请求链路追踪
- 🚬 一、概述
- 🚬 二、快速入门
- 🚭 1、安装启动zipkin。 java –jar zipkin.jar
- 🚭 2、访问zipkin web界面。 [http://localhost:9411/](http://localhost:9411/)
- 🚭 3、在服务提供方和消费方分别引入 sleuth 和 zipkin 依赖
- 🚭 4、分别配置服务提供方和消费方。
- 🚭 5、启动,测试
😹 作者: gh-xiaohe
😻 gh-xiaohe的博客
😽 觉得博主文章写的不错的话,希望大家三连(✌关注,✌点赞,✌评论),多多支持一下!!!
超大型公司才会用到处理大规模微服务的技术。
🚏 第十三章 分布式配置中心
🚬 一、Config 概述
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-k8HdY1fb-1675939059100)(SpringCloud.assets/image-20220418081959807.439382b4.png)]](https://img-blog.csdnimg.cn/92c6eddede9d45f888efcf95e6d22d40.png)
Spring Cloud Config 解决了在分布式场景下多环境配置文件的管理和维护。
好处:
1、集中管理配置文件
2、不同环境不同配置,动态化的配置更新 dev test
3、配置信息改变时,不需要重启即可更新配置信息到服务
🚬 二、Config 快速入门
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DisRoUt6-1675939059101)(SpringCloud.assets/image-20220418082533367.271fa629.png)]](https://img-blog.csdnimg.cn/fb87599a36354622896d7bcbb1a688fe.png)
🚭 config-server:
🛹 1、使用gitee创建远程仓库,上传配置文件
创建gitee 远程仓库,新建config-dev.yml文件,内容如下:
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Z8rIVXH6-1675939059101)(SpringCloud.assets/image-20230121122342868.png)]](https://img-blog.csdnimg.cn/d0ef5aad55dd456ebfc428d6171d50c7.png)
server:port: 8000eureka:instance:hostname: localhost # 主机名prefer-ip-address: true # 将当前实例的ip注册到eureka server 中。默认是false 注册主机名ip-address: 127.0.0.1 # 设置当前实例的ipinstance-id: ${eureka.instance.ip-address}:${spring.application.name}:${server.port} # 设置web控制台显示的 实例idlease-renewal-interval-in-seconds: 3 # 每隔3 秒发一次心跳包lease-expiration-duration-in-seconds: 9 # 如果9秒没有发心跳包,服务器呀,你把我干掉吧~client:service-url:defaultZone: http://eureka-server1:8761/eureka,http://eureka-server2:8762/eureka # eureka服务端地址,将来客户端使用该地址和eureka进行通信
spring:application:name: eureka-provider # 设置当前应用的名称。将来会在eureka中Application显示。将来需要使用该名称来获取路径gh: xiaohe
🛹 2、导入 config-server 依赖
<!-- config-server --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId></dependency>
🛹 3、搭建 config-server 模块
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;@SpringBootApplication
@EnableConfigServer // 启用config server功能
public class ConfigServerApp {public static void main(String[] args) {SpringApplication.run(ConfigServerApp.class,args);}
}
🛹 4、编写配置,设置 gitee 远程仓库地址
server:port: 9527spring:application:name: config-server# spring cloud configcloud:config:server:# git 的 远程仓库地址git:uri: https://gitee.com/ydlclass_cch/ydlclass-configs.gitlabel: master # 分支配置
🛹 5、测试访问远程配置文件
http://localhost:9527/master/config-dev.yml
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uq4uQxBc-1675939059102)(SpringCloud.assets/image-20220418083733698.508dfd18.png)]](https://img-blog.csdnimg.cn/bf634bccf69c4dd88d0036632ba3036e.png)
🚭 config-client: provider
案例 : 01eureka-provider-8000 改造
🛹 1、导入 starter-config 依赖
<!--config client --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-config</artifactId></dependency>
🛹 2、配置config server 地址,读取配置文件名称等信息
bootstrap.yml
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-d7j1k2sv-1675939059102)(SpringCloud.assets/image-20230121125859568.png)]](https://img-blog.csdnimg.cn/b84df57fc272476b919010d0f3638ba9.png)
# 配置config-server地址
# 配置获得配置文件的名称等信息
spring:cloud:config:# 配置config-server地址uri: http://localhost:9527# 配置获得配置文件的名称等信息name: provider # 文件名profile: dev # profile指定, config-dev.ymllabel: master # 分支
🛹 3、获取配置值
GoodsController
@Value("${gh}")private String xiaoHe;goods.setTitle(goods.getTitle()+"|端口号:"+ port + " xiaoHe" + xiaoHe );
🛹 4、启动测试
http://localhost:8000/goods/findById/9
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-7uzvY3a4-1675939059102)(SpringCloud.assets/image-20220418084608302.978afefa.png)]](https://img-blog.csdnimg.cn/55a1a66d75ed44d08b17dcb2795a8b28.png)
🚭 Config 客户端刷新
gitee的配置文件发生改变 微服务也应该发生变化 , 通过查看 微服务 中的值 没有发生改变,配置中心的值已经发生改变
解决办法:通知微服务
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5FmeRLgN-1675939059103)(SpringCloud.assets/image-20220418085057098.ae365b9f.png)]](https://img-blog.csdnimg.cn/536c237cd6ca42dfaf0e75260336b00a.png)
🛹 1、在 config 客户端引入 actuator 依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
🛹 2、获取配置信息类上,添加 @RefreshScope 注解
获取配置信息类上,添加 @RefreshScope 注解
@RefreshScope // 开启刷新功能
🛹 3、添加配置
bootstrap.yml
management:endpoints:web:exposure:include: '*'
🛹 4、使用curl工具发送post请求
curl -X POST http://localhost:8000/actuator/refresh 告诉你要进行刷新,或者使用ApiPost 等软件
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-or3fvUdX-1675939059103)(SpringCloud.assets/image-20220418085907801.edb89cde.png)]](https://img-blog.csdnimg.cn/d603eaa42b4f4b4a9628af4756765fe2.png)
测试:值已经改变
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GByAquUs-1675939059103)(SpringCloud.assets/image-20220418085930400.9adcb0c7.png)]](https://img-blog.csdnimg.cn/39fd4eff38504778abae12eb81253dba.png)
🚬 三、Config 集成Eureka
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3umw00d3-1675939059104)(SpringCloud.assets/image-20220418090254336.8b4469ba.png)]](https://img-blog.csdnimg.cn/f5d756f98ad44041baaf9885b514faa8.png)
🚭 config-client配置:
<!-- eureka-client --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency>
主启动
@EnableEurekaClient
bootstrap.yml
# 配置config-server地址
# 配置获得配置文件的名称等信息
spring:cloud:config:# 配置config-server地址# uri: http://localhost:9527# 配置获得配置文件的名称等信息name: config # 文件名profile: dev # profile指定, config-dev.ymllabel: master # 分支discovery:enabled: trueservice-id: CONFIG-SERVER # 不写死 找具体的配置中心
# 打开端点
management:endpoints:web:exposure:include: '*'
🚭 config-server配置:
<!-- eureka-client --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency>
主启动
@EnableEurekaClient
application.yml
eureka:client:service-url:defaultZone: http://localhost:8761/eureka
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JbpVtewJ-1675939059104)(SpringCloud.assets/image-20220418093808497.b6035ff7.png)]](https://img-blog.csdnimg.cn/30b4d98f503e48cf921c21db2e8c63c5.png)
🚏 第十四章 SpringCloud Bus消息总线
远程的配置文件更新了,运维只需要发一个请求,所有用到这个配置文件的几百个应用更新了。
🚬 一、Bus 概述
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ikyokS46-1675939059105)(SpringCloud.assets/image-20230125182110374.png)]](https://img-blog.csdnimg.cn/9a8acb2119c842949905a727e481226c.png)
Spring Cloud Bus 是用轻量的消息中间件将分布式的节点连接起来,可以用于广播配置文件的更改或者服务的监控管理。关键的思想就是,消息总线可以为微服务做监控,也可以实现应用程序之间相通信。
Spring Cloud Bus 可选的消息中间件包括 RabbitMQ 和 Kafka 。
🚬 二、RabbitMQ(message queue 消息对列)
window 安装教程 :https://www.cnblogs.com/jfl-xx/p/10250184.html
文件分享 :https://share.weiyun.com/1JUdp5qf
作用:消息的生产者 已发送消息 , 发送到 MQ 中 让消息的消费者,来监听到消息
三大功能:异步、解耦、削峰填谷
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-K2W7Rad7-1675939059105)(SpringCloud.assets/image-20200613074044506.2b1f2272.png)]](https://img-blog.csdnimg.cn/8a11b2a55787448ea3bd7c02945be25a.png)
结构
- 1、生产者: 和交换机建立一个 常链接 后通过 常链接中的 channel(频道、管道),把消息发动到 Exchange(交换机)
- 2、RabbitMQ 通过绑定关系,把消息通过交换机 分发到一个或者 多个对列中
- 3、消费者:监听一个对列,消费者 和一个对列 建立一个常链接, 对列中有了消息,就会通过常链接 中的 channel 推送到我们的消费者中
RabbitMQ 提供了 6 种工作模式: 简单模式、工作对列 work queues、Publish/Subscribe 发布与订阅模式、Routing 路由模式、Topics 主题模式、RPC 远程调用模式(远程调用,不太算 MQ;是一个思想,暂不作介绍)。
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2yYRIYGE-1675939059105)(SpringCloud.assets/image-20200613074109383.dc1a9615.png)]](https://img-blog.csdnimg.cn/5ee3435d27ac4f8a85a5eaf6b0af5b50.png)
🚬 三、Bus 快速入门-运维
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Uif8cNf3-1675939059106)(SpringCloud.assets/image-20200613074052830.5aedea61.png)]](https://img-blog.csdnimg.cn/88af9893b1c0476989a3dcc3f1687b6d.png)
🚭 1、分别在 config-server 和 config-client中引入 bus依赖:bus-amqp
<!-- bus --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bus-amqp</artifactId></dependency><!-- 端点打开 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
🚭 2、分别在 config-server 和 config-client中配置 RabbitMQ
🛹 server 的配置文件:
server:port: 9527spring:application:name: config-server# spring cloud configcloud:config:server:# git 的 远程仓库地址git:uri: https://gitee.com/ydlclass_cch/ydlclass-configs.gitlabel: master # 分支配置#配置rabbitmq信息rabbitmq:host: localhostport: 5672username: guestpassword: guestvirtual-host: /# 将自己注册到eureka中
eureka:client:service-url:defaultZone: http://localhost:8761/eureka# 暴露bus的刷新端点
management:endpoints:web:exposure:include: 'bus-refresh'
🛹 client的配置文件 bootstrap.yml
# 配置config-server地址
# 配置获得配置文件的名称等信息
spring:cloud:config:# 配置config-server地址# uri: http://localhost:9527# 配置获得配置文件的名称等信息name: config # 文件名profile: dev # profile指定, config-dev.ymllabel: master # 分支# 从注册中心去寻找config-server地址discovery:enabled: trueservice-id: CONFIG-SERVER#配置rabbitmq信息rabbitmq:host: localhostport: 5672username: guestpassword: guestvirtual-host: /management:endpoints:web:exposure:include: '*'
🚭 3、在config-server中设置暴露监控断点:bus-refresh
# 暴露bus的刷新端点
management:endpoints:web:exposure:include: 'bus-refresh'
bus自动在mq中建立交换机
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bv28KtNq-1675939059106)(SpringCloud.assets/image-20230125185400454.png)]](https://img-blog.csdnimg.cn/47a7677cfa8942ec89b0cda4aeeef2fa.png)
只要微服务起起来,自动在mq中,建立队列,和交换机绑定

🚭 4、启动测试
🛹 1、git配置改变

🛹 2、往配置中心发请求
curl -X POST http://localhost:9527/actuator/bus-refresh
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wTBevuO2-1675939059107)(SpringCloud.assets/image-20230125195237019.png)]](https://img-blog.csdnimg.cn/2b0ad1f9e00141bf9781b1e619a03f49.png)
🛹 3、微服务自动重启
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-k811WYpZ-1675939059107)(SpringCloud.assets/image-20220418104702500.bbdf21ca.png)]](https://img-blog.csdnimg.cn/457781c27e514016b5572f8c1c71cea9.png)
🛹 4、访问微服务,发现配置已经改变
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-FH2P3Yf1-1675939059107)(SpringCloud.assets/image-20220418104819862.b829a33e.png)]](https://img-blog.csdnimg.cn/b5a6757232994d098ef7b90912177cf0.png)
🚏 第十五章 SpringCloud Stream消息驱动
🚬 一、Stream 概述
问题:更换消息对列,所属所涉及到的代码都会发生改变
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-c2TQxv6A-1675939059107)(SpringCloud.assets/image-20230126222531322.png)]](https://img-blog.csdnimg.cn/ae36e41a38b4443b8f471cf002dff92f.png)
解决问题:Stream
-
1、Spring Cloud Stream 是一个构建消息驱动微服务应用的框架。
-
2、Stream 解决了开发人员无感知的使用消息中间件的问题,因为Stream对消息中间件的进一步封装,可以做到代码层面对中间件的无感知,甚至于动态的切换中间件,使得微服务开发的高度解耦,服务可以关注更多自己的业务流程。
-
3、Spring Cloud Stream目前支持两种消息中间件RabbitMQ和Kafka
-
就像jdbc一样
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jyFCvpm7-1675939059108)(SpringCloud.assets/image-20220418111643163.1006efdf.png)]](https://img-blog.csdnimg.cn/ab65b154b6434598bada77059e7b6552.png)
🚭 Stream 组件
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kn9le2Cn-1675939059108)(SpringCloud.assets/image-20230125222933773.png)]](https://img-blog.csdnimg.cn/6fce171b3fc54505bf28dbc737153558.png)
- Spring Cloud Stream 构建的应用程序与消息中间件之间是通过绑定器Binder 相关联的 。绑定器对于应用程序而言起到了隔离作用, 它使得不同消息中间件的实现细节对应用程序来说是透明的。
- binding 是我们通过配置把应用和spring cloud stream 的 binder 绑定在一起
- output:发送消息 Channel,内置 Source接口
- input:接收消息 Channel,内置 Sink接口
🚬 二、Stream 消息生产者 stream-producer
<dependencies><!--spring boot web--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- stream --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-stream-rabbit</artifactId></dependency></dependencies>
@SpringBootApplication
public class StreamProducerApp8000 {public static void main(String[] args) {SpringApplication.run(StreamProducerApp8000.class,args);}
}
server:port: 8000spring:cloud:stream:# 定义绑定器,绑定到哪个消息中间件上binders:ydlclass_binder: # 自定义的绑定器名称type: rabbit # 绑定器类型environment: # 指定mq的环境spring:rabbitmq:host: localhostport: 5672username: guestpassword: guestvirtual-host: /bindings:output: # channel名称binder: ydlclass_binder #指定使用哪一个binderdestination: ydlclass_exchange # 消息目的地(交换机)
🚭 消息发送类
MessageProducer
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SgxeCz0d-1675939059108)(SpringCloud.assets/image-20230126154947920.png)]](https://img-blog.csdnimg.cn/156cf4fa4a204c3fa6741f1436dd30af.png)
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;@Component
@EnableBinding(Source.class)//这个类是stream的发送者
public class MessageProducer {@AutowiredMessageChannel output;public void send(String msg){output.send(MessageBuilder.withPayload(msg).build());System.out.println("MessageProducer 确实发了消息了!");}
}
🚭 调用的controller
ProducerController
import com.ydlclass.stream.producer.MessageProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("test")
public class ProducerController {@AutowiredMessageProducer messageProducer;//业务逻辑@GetMapping("/send")public String send(){//发消息String msg="使用stream来发消息了!";messageProducer.send(msg);return "success!";}
}

🚬 三、Stream 消息消费者 stream-consumer
<dependencies><!--spring boot web--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- stream --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-stream-rabbit</artifactId></dependency></dependencies>
@SpringBootApplication
public class StreamConsumerApp9000 {public static void main(String[] args) {SpringApplication.run(StreamConsumerApp9000.class,args);}
}
server:port: 9000spring:cloud:stream:# 定义绑定器,绑定到哪个消息中间件上binders:ydlclass_binder: # 自定义的绑定器名称type: rabbit # 绑定器类型environment: # 指定mq的环境spring:rabbitmq:host: localhostport: 5672username: guestpassword: guestvirtual-host: /bindings:input: # channel名称binder: ydlclass_binder #指定使用哪一个binderdestination: ydlclass_exchange # 消息目的地
🚭 消息接收类
MessageListener
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sHhyMlpX-1675939059109)(SpringCloud.assets/image-20230126155008265.png)]](https://img-blog.csdnimg.cn/4dd36e770d41451e892bc00c3c7beaa5.png)
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;/*** 消息接收类*/
@EnableBinding(Sink.class) // 这个类是stream 的消费者监听类
@Component
public class MessageListener {@StreamListener(Sink.INPUT) // 接到到消息,立马执行下面代码public void receive(Message message){System.out.println(message);System.out.println(message.getPayload());}
}

🚏 第十六章 SpringCloud Sleuth分布式请求链路追踪
🚬 一、概述
问题?
想看一下,一个请求过来,设计到多少个微服务,这就是所谓的链路追踪
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-YgyxSIAV-1675939059110)(SpringCloud.assets/image-20230126214844650.png)]](https://img-blog.csdnimg.cn/87fc6f2be6c8498c806908604427337e.png)
Spring Cloud Sleuth 其实是一个工具,它在整个分布式系统中能跟踪一个用户请求的过程,捕获这些跟踪数据,就能构建微服务的整个调用链的视图,这是调试和监控微服务的关键工具。
- 1、耗时分析
- 2、可视化错误
- 3、链路优化
Zipkin 是 Twitter 的一个开源项目,它致力于收集服务的定时数据,以解决微服务架构中的延迟问题,包括数据的收集、存储、查找和展现。
Zipkin 和 Sleuth共同完成:Sleuth 手机数据 传到 Zipkin 上
🚬 二、快速入门
🚭 1、安装启动zipkin。 java –jar zipkin.jar
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AFR3cZx5-1675939059110)(SpringCloud.assets/image-20220418185033323.76dc027c.png)]](https://img-blog.csdnimg.cn/a6a3867ea911489fa2d4ec037b8df10c.png)
🚭 2、访问zipkin web界面。 http://localhost:9411/
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-hBhX3c6n-1675939059110)(SpringCloud.assets/image-20200613080015686.e297485f.png)]](https://img-blog.csdnimg.cn/4582d8ccce0c4426a39534ea717dd356.png)
🚭 3、在服务提供方和消费方分别引入 sleuth 和 zipkin 依赖
<!-- sleuth-zipkin --><!--<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-sleuth</artifactId></dependency>--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-zipkin</artifactId></dependency>
🚭 4、分别配置服务提供方和消费方。
provider
spring:application:name: feign-provider# 收集的数据传到 zipkin上 zipkin:base-url: http://localhost:9411/ # 设置zipkin的服务端路径# 收集这些信息sleuth:sampler:probability: 1 # 采集率 默认 0.1 百分之十。
consumer
spring:application:name: feign-consumer # 设置当前应用的名称。将来会在eureka中Application显示。将来需要使用该名称来获取路径# 收集的数据传到 zipkin上 zipkin:base-url: http://localhost:9411/ # 设置zipkin的服务端路径# 收集这些信息sleuth:sampler:probability: 1 # 采集率 默认 0.1 百分之十。
🚭 5、启动,测试
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-g6qjiPZe-1675939059110)(SpringCloud.assets/image-20230126222633356.png)]](https://img-blog.csdnimg.cn/ca579d2f18254323a6782a160a1df991.png)
相关文章:
SpringCloud 中 Config、Bus、Stream、Sleuth
文章目录🚏 第十三章 分布式配置中心🚬 一、Config 概述🚬 二、Config 快速入门🚭 config-server:🛹 1、使用gitee创建远程仓库,上传配置文件🛹 2、导入 config-server 依赖…...
Quantum 构建工具使用新的 TTP 投递 Agent Tesla
Zscaler 的研究人员发现暗网上正在出售名为 Quantum Builder 的构建工具,该工具可以投递 .NET 远控木马 Agent Tesla。与过去的攻击行动相比,本次攻击转向使用 LNK 文件。 Quantum Builder 能够创建恶意文件,如 LNK、HTA 与 PowerShell&…...
浏览器中的 JavaScript 执行机制
思维导图 本文为反复学习极客时间-《浏览器的工作原理与实践》-浏览器中的 JavaScript 执行机制章节中的一些思考与记录。 一些重要概念 变量提升 所谓的变量提升,是指在 JavaScript 代码执行过程中,JavaScript 引擎把变量的声明部分和函数的声明部分…...
kafka集群搭建及问题
一、zookeeper集群搭建 1、创建文件夹 cd /home mkdir zookeeper 2、下载 cd zookeeper wget https://downloads.apache.org/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz 解压到当前文件夹 tar -zxvf apache-zookeeper-3.8.0-bin.tar.gz 文件夹重命…...
不要忽视web渗透测试在项目中起到的重要性
在当前数字化环境中,IT的一个里程碑式增长便是公司组织和企业数字化。为了扩大市场范围和方便业务,许多组织都在转向互联网。这导致了一股新的商业浪潮,它创造了网络空间中的商业环境。通过这种方式,公司和客户的官方或机密文件都…...
Early Stopping中基于测试集(而非验证集)上的表现选取模型的讨论
论文中一般都是用在验证集上效果最好的模型去预测测试集,多次预测的结果取平均计算准确率或者mAP值,而不是单纯的取一次验证集最好的结果作为论文的结果。如果你在写论文的过程中,把测试集当做验证集去验证的话,这其实是作假的&am…...
appium ios真机自动化环境搭建运行(送源码)
appium ios真机自动化环境搭建&运行(送源码) 目录:导读 (1)安装JDK,并配置环境变量,方法如下: (2)安装Xcode、Xcode commandline tools和iOS模拟器 &…...
米尔基于ARM嵌入式核心板的电池管理系统(BMS)
BMS全称是Battery Management System,电池管理系统。它是配合监控储能电池状态的设备,主要就是为了智能化管理及维护各个电池单元,防止电池出现过充电和过放电,延长电池的使用寿命,监控电池的状态。 图片摘自网络 电池…...
Java后端项目IDEA配置代码规范检查,使用checkStyle实现
最近的Java后端项目想实现代码的规范检查,调研了一圈,终于找到了简单的方式实现:以下是常见的几种方案: 1、在客户端做 git hook,主要是用 pre-commit 这个钩子。前端项目中常见的 husky 就是基于此实现的。但缺点也很…...
Nginx_4
Nginx负载均衡 负载均衡概述 早期的网站流量和业务功能都比较简单,单台服务器足以满足基本的需求,但是随着互联网的发展,业务流量越来越大并且业务逻辑也跟着越来越复杂,单台服务器的性能及单点故障问题就凸显出来了,…...
linux Ubuntu KUbuntu 系统安装相关
系统安装 本来想快到中午的时候调试一下服务器上的http请求接收代码。我的电脑上装的是kali的U盘系统,然后我的U盘居然找不到了(然后之前安装的系统不知道是否是写入软件的原因,没办法解析DNS,我都用的转发的,这让我体验非常差。kali的系统工具很多&…...
个人信息保护认证
个人信息保护认证是证明个人信息处理者在认证范围内开展的个人信息收集、存储、使用、加工、传输、提供、公开、删除以及跨境等处理活动符合认证依据标准要求。适用范围 本规则依据《中华人民共和国认证认可条例》制定,规定了对个人信息处理者开展个人信息收集、存储…...
Negative Prompt in Stable Diffusion
必读链接:https://www.reddit.com/r/StableDiffusion/comments/z7salo/with_the_right_prompt_stable_diffusion_20_can_do/ A lot of people have noticed that Negative Prompt works wonders in 2.0, and works even better in 2.1. Negative hints are the op…...
MLX90316KGO-BDG-100-RE传感器 旋转位置 角度测量
介绍MLX90316是Tria⊗is旋转位置传感器,提供在设备表面旋转的小偶极磁铁(轴端磁铁)的绝对角位置。得益于其表面的集成磁集中器(IMC),单片设备以非接触式方式感知应用磁通量密度的水平分量。这种独特的传感原理应用于旋转位置传感器,可在机械(…...
Reflections反射包在springboot jar环境下扫描不到class排查过程
需求: 要实现指定pkg(如com.qiqitrue.test.pojo)扫描包下所有class类信息:使用代码如下 使用的版本:0.10.2(截至目前是最新版)发现只能在idea编译期间可以获取得到(也就是在开发阶段…...
黑马】后台项目171集
将近一个月没有练习了,找到之后果然打不开出了问题【问题】运行代码打开网页后,发现不能正常登录,一开始还以为是密码记错了,后来发现是数据库没有正常启动,phpstudy中的数据库一直是启动状态,关闭不了。【…...
Qt 5 架构和特点
Qt 5 模块构架: 模块:功能:Qt CoreQt 5 的核心类库,每个模块都建立在Core上Qt GUI图形用户界面开发的最基础的类库Qt Widgets提供c用户界面部件(是对Qt GUI的拓展)Qt SQL对数据库进行操作Qt Multimedia、…...
转换符说明使用方法(在printf函数中)
目录 一些常见的转换说明及打印结果: printf()的转换说明修饰符 printf()函数打印数据指令时要与代打印数据的类型相匹配才行。 如%d %c %ld......这些符号叫做转换说明。代表着数据转化成显示的形式。 一些常见的…...
针灸-基本任脉督脉
这里写自定义目录标题 丈量 同身丈下针深浅一般入穴的方法成人 幼儿 不同入穴方式现代常用针概念十二经 纳天干**天干**地支表里关系筋络任脉中脘穴:梅花灸巨阙穴廉泉穴督脉长强腰俞命门阳关悬枢脊中筋缩眼诊 癫痫至阳消渴...
信息系统与信息化
1.1 信息系统与信息化 1.1.1 信息的基本概念 信息质量属性(掌握)信息传输模型 1.1.2 信息系统的基本概念1.1.3 信息化的基本概念 信息化的五个层次信息化基本内涵信息化的基本概念(了解)六要素关系图(掌握) 1.1.4 信息系统生命周…...
网络编程(Modbus进阶)
思维导图 Modbus RTU(先学一点理论) 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议,由 Modicon 公司(现施耐德电气)于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…...
基于FPGA的PID算法学习———实现PID比例控制算法
基于FPGA的PID算法学习 前言一、PID算法分析二、PID仿真分析1. PID代码2.PI代码3.P代码4.顶层5.测试文件6.仿真波形 总结 前言 学习内容:参考网站: PID算法控制 PID即:Proportional(比例)、Integral(积分&…...
循环冗余码校验CRC码 算法步骤+详细实例计算
通信过程:(白话解释) 我们将原始待发送的消息称为 M M M,依据发送接收消息双方约定的生成多项式 G ( x ) G(x) G(x)(意思就是 G ( x ) G(x) G(x) 是已知的)࿰…...
2025盘古石杯决赛【手机取证】
前言 第三届盘古石杯国际电子数据取证大赛决赛 最后一题没有解出来,实在找不到,希望有大佬教一下我。 还有就会议时间,我感觉不是图片时间,因为在电脑看到是其他时间用老会议系统开的会。 手机取证 1、分析鸿蒙手机检材&#x…...
2023赣州旅游投资集团
单选题 1.“不登高山,不知天之高也;不临深溪,不知地之厚也。”这句话说明_____。 A、人的意识具有创造性 B、人的认识是独立于实践之外的 C、实践在认识过程中具有决定作用 D、人的一切知识都是从直接经验中获得的 参考答案: C 本题解…...
SQL慢可能是触发了ring buffer
简介 最近在进行 postgresql 性能排查的时候,发现 PG 在某一个时间并行执行的 SQL 变得特别慢。最后通过监控监观察到并行发起得时间 buffers_alloc 就急速上升,且低水位伴随在整个慢 SQL,一直是 buferIO 的等待事件,此时也没有其他会话的争抢。SQL 虽然不是高效 SQL ,但…...
wpf在image控件上快速显示内存图像
wpf在image控件上快速显示内存图像https://www.cnblogs.com/haodafeng/p/10431387.html 如果你在寻找能够快速在image控件刷新大图像(比如分辨率3000*3000的图像)的办法,尤其是想把内存中的裸数据(只有图像的数据,不包…...
【Elasticsearch】Elasticsearch 在大数据生态圈的地位 实践经验
Elasticsearch 在大数据生态圈的地位 & 实践经验 1.Elasticsearch 的优势1.1 Elasticsearch 解决的核心问题1.1.1 传统方案的短板1.1.2 Elasticsearch 的解决方案 1.2 与大数据组件的对比优势1.3 关键优势技术支撑1.4 Elasticsearch 的竞品1.4.1 全文搜索领域1.4.2 日志分析…...
pycharm 设置环境出错
pycharm 设置环境出错 pycharm 新建项目,设置虚拟环境,出错 pycharm 出错 Cannot open Local Failed to start [powershell.exe, -NoExit, -ExecutionPolicy, Bypass, -File, C:\Program Files\JetBrains\PyCharm 2024.1.3\plugins\terminal\shell-int…...
沙箱虚拟化技术虚拟机容器之间的关系详解
问题 沙箱、虚拟化、容器三者分开一一介绍的话我知道他们各自都是什么东西,但是如果把三者放在一起,它们之间到底什么关系?又有什么联系呢?我不是很明白!!! 就比如说: 沙箱&#…...

