使用消息总线传递服务调用信息

This commit is contained in:
winLsy
2018-02-07 16:59:34 +08:00
parent b9140edfc6
commit 7d2f6a1fbc
17 changed files with 79 additions and 74 deletions
@@ -68,7 +68,10 @@ public class MsAuthenticationSuccessHandler extends SavedRequestAwareAuthenticat
log.info("登录成功,开始授权令牌");
//1.校验clientId和clientSecret是否对应
String header = request.getHeader("Authorization");
if (header == null && !header.startsWith("Basic ")) {
if (header==null){
throw new UnapprovedClientAuthenticationException("请求头中client信息不存在");
}
if (!header.startsWith("Basic ")) {
throw new UnapprovedClientAuthenticationException("请求头中client信息不存在");
}
String[] tokens = this.extractAndDecodeHeader(header, request);
+4 -2
View File
@@ -18,8 +18,10 @@
用户中心默认启动端口号10010,健康检查端口10011.
### 认证中心 oauth
认证中心默认启动端口号10012,健康检查端口号10013.
### 监控中心
监控中心的默认启动端口是10018
### 请求监控
请求监控的默认启动端口是10018
### 服务调用监控
服务调用监控的默认启动端口是10020
### 后台管理界面 manage-system
使用vue.js搭建后台管理界面
## 项目相关约束
+5 -1
View File
@@ -65,9 +65,13 @@
<artifactId>spring-retry</artifactId>
</dependency>
<!--检测生成服务调用数据-->
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-zipkin</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<!--jwt令牌解析-->
<dependency>
@@ -23,7 +23,7 @@ public class ValidateJwtToken {
return ServerResponse.error();
}
String token = StringUtils.substringAfter(authorization, "bearer ");
if (token==null){
if (StringUtils.isBlank(token)){
return ServerResponse.error();
}
//解析jwt
-2
View File
@@ -1,5 +1,3 @@
# 微服务系统监控中心
#### 集群服务熔断情况的监控
界面访问地址`/hystrix`。可使用`http://.../turbine.stream?cluster={集群名称之一}`访问
#### 集群服务调用情况的监控
界面访问地址`/`
+9 -9
View File
@@ -3,11 +3,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>monitor-center</artifactId>
<artifactId>monitor-turbine</artifactId>
<packaging>jar</packaging>
<name>ms-monitor-center</name>
<description>ms-monitor-center</description>
<name>ms-monitor-turbine</name>
<description>ms-monitor-turbine</description>
<parent>
<groupId>com.micro.fast</groupId>
@@ -54,14 +54,14 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>
<!--服务调展示界面-->
<!--配置客户端配置刷新-->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<!--测试-->
<dependency>
@@ -90,7 +90,7 @@
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>ms-monitor-center</finalName>
<finalName>ms-monitor-turbine</finalName>
</build>
@@ -5,7 +5,6 @@ import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
import zipkin.server.EnableZipkinServer;
/**
* @author lsy
@@ -13,13 +12,11 @@ import zipkin.server.EnableZipkinServer;
@SpringCloudApplication
//集群熔断降级情况的聚合展示
@EnableTurbine
//集群间服务调用情况的聚合展示
@EnableZipkinServer
@EnableHystrixDashboard
@EnableHystrix
public class MsMonitorCenterApplication {
public class MsMonitorTurbineApplication {
public static void main(String[] args) {
SpringApplication.run(MsMonitorCenterApplication.class, args);
SpringApplication.run(MsMonitorTurbineApplication.class, args);
}
}
@@ -3,7 +3,7 @@ spring:
config:
profile: dev
label: master
name: monitorcenter
name: turbine
discovery:
service-id: config-server
enabled: true
@@ -14,4 +14,4 @@ eureka:
serviceUrl:
defaultZone: http://micro:fast@www.register1.com:10002/eureka/,http://micro:fast@www.register2.com:10004/eureka/ #配置所有的注册中心
instance:
hostname: www.monitorcenter.com
hostname: www.turbine.com
@@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MsMonitorCenterApplicationTests {
public class MsMonitorTurbineApplicationTests {
@Test
public void contextLoads() {
-2
View File
@@ -1,5 +1,3 @@
# 微服务系统监控中心
#### 集群服务熔断情况的监控
界面访问地址`/hystrix`。可使用`http://.../turbine.stream?cluster={集群名称之一}`访问
#### 集群服务调用情况的监控
界面访问地址`/`
+20 -25
View File
@@ -3,11 +3,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>monitor-center</artifactId>
<artifactId>monitor-zipkin</artifactId>
<packaging>jar</packaging>
<name>ms-monitor-center</name>
<description>ms-monitor-center</description>
<name>ms-monitor-zipkin</name>
<description>ms-monitor-zipkin</description>
<parent>
<groupId>com.micro.fast</groupId>
@@ -35,34 +35,30 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--调用其他服务的时候熔断情况的图形化展示-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<!--调用其他服务的时候熔断情况的图形化展示-->
<!--链路追踪-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<!--对服务的断路由情况进行聚合-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<!--服务调展示界面-->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>io.zipkin.java</groupId>-->
<!--<artifactId>zipkin-server</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
</dependency>
<!--配置客户端配置刷新-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<!--测试-->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -90,8 +86,7 @@
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>ms-monitor-center</finalName>
<finalName>ms-monitor-zipkin</finalName>
</build>
</project>
@@ -1,25 +1,20 @@
package com.micro.fast.monitor.center;
package com.micro.fast.monitor.zipkin;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
import zipkin.server.EnableZipkinServer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.sleuth.zipkin.stream.EnableZipkinStreamServer;
/**
* @author lsy
*/
@SpringCloudApplication
//集群熔断降级情况的聚合展示
@EnableTurbine
@SpringBootApplication
@EnableDiscoveryClient
//集群间服务调用情况的聚合展示
@EnableZipkinServer
@EnableHystrixDashboard
@EnableHystrix
public class MsMonitorCenterApplication {
@EnableZipkinStreamServer
public class MsMonitorZipkinApplication {
public static void main(String[] args) {
SpringApplication.run(MsMonitorCenterApplication.class, args);
SpringApplication.run(MsMonitorZipkinApplication.class, args);
}
}
@@ -3,7 +3,7 @@ spring:
config:
profile: dev
label: master
name: monitorcenter
name: zipkin
discovery:
service-id: config-server
enabled: true
@@ -14,4 +14,4 @@ eureka:
serviceUrl:
defaultZone: http://micro:fast@www.register1.com:10002/eureka/,http://micro:fast@www.register2.com:10004/eureka/ #配置所有的注册中心
instance:
hostname: www.monitorcenter.com
hostname: www.zipkin.com
+5 -1
View File
@@ -66,9 +66,13 @@
<artifactId>spring-retry</artifactId>
</dependency>
<!--检测生成服务调用数据-->
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-zipkin</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<!--测试-->
<dependency>
+2 -1
View File
@@ -61,7 +61,8 @@
<module>config-server</module>
<module>register-center1</module>
<module>register-center2</module>
<module>monitor-center</module>
<module>monitor-turbine</module>
<module>monitor-zipkin</module>
<module>oauth</module>
<module>gateway</module>
<module>upms</module>
+5 -1
View File
@@ -76,9 +76,13 @@
<artifactId>spring-retry</artifactId>
</dependency>
<!--检测生成服务调用数据-->
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-zipkin</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<!--测试-->
<dependency>
+8 -4
View File
@@ -66,10 +66,14 @@
<artifactId>spring-retry</artifactId>
</dependency>
<!--检测生成服务调用数据-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-zipkin</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<!--测试-->
<dependency>
<groupId>org.springframework.boot</groupId>