首页 技术 正文
技术 2022年11月9日
0 收藏 437 点赞 4,033 浏览 1674 个字

用spring cloud 微服务框架有一段时间了有一些坑点在这里给大家记录一下希望大家用得着

1、当我们使用聚合性能监控的时候,我们采用 rabbitmq作为消息中间件来收集性能信息最后在使用TurbineStream将信息进行聚合

  这个工具聚合是根据“应用名+方法名”进行求和汇总的

  如下代码:

  

@HystrixCommand(commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "20000") }, threadPoolProperties = {
@HystrixProperty(name = "coreSize", value = "64") }, threadPoolKey = "test1")
@GetMapping("/testpro3")
public int getStringtest2(){ //throw new Exception("ddd");
return 1;
}

  这里的聚合就是“应用名+getStringtest2”

  spring cloud 实践坑点记录

  这样的话就会存在一个问题在不同的两个类都是被@RestController标记并且都对外发布接口的url不同功能也不同

  如下:

  

@RestController
public class testRest1 {
@HystrixCommand(commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "20000") }, threadPoolProperties = {
@HystrixProperty(name = "coreSize", value = "64") }, threadPoolKey = "test1")
@GetMapping("/testpro3")
public int getStringtest2(){ //throw new Exception("ddd");
return 1;
}
}
@RestController
public class testRest1 {
@HystrixCommand(commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "20000") }, threadPoolProperties = {
@HystrixProperty(name = "coreSize", value = "64") }, threadPoolKey = "test1")
@GetMapping("/testpro4")
public int getStringtest2(){ //throw new Exception("ddd");
return 1;
}
}

  假如像上面的代码在一个工程里面就会吧这两个方法的性能进行聚合,可能我们在项目中很少出现这种情况但是 墨菲定律 有可能发生的事情就一定会发生

2、配置文件服务器刷新坑点

  当我们的spring boot应用使用配置中心进行配置加载的时候,当我们的配置文件更新的时候去刷新通知我们的URL通常是这样的

  10.10.12.51:8888/bus/refresh?destination=spring-cloud-demo:8082进行post请求

  上面的url是没问题的但是我们可能会看到EUREKA注册中心对应用名全是大写的 如下

  spring cloud 实践坑点记录

  这样就会给我们一个误导是不是用全部是大写的应用名也可以啊??向下面这样

  

10.10.12.51:8888/bus/refresh?destination=SPRING-CLOUD-DEMO:8082

  经过测试这样是不行的,所以请大家注意

服务监控信息到底是“主动推送”还是“被动扫描”???

spring boot +RabbitMQ +InfluxDB+Grafara监控实践

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,557
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898