【问题标题】:Spring Cloud Gateway routes do not work and Hystrix Dashboard crashed loadingSpring Cloud Gateway 路由不起作用,Hystrix Dashboard 崩溃加载
【发布时间】:2021-06-27 20:17:48
【问题描述】:

在来自 youtube 的 tutorial 中,作者使用 Spring Cloud Gateway、Hystrix、Netflix,并使用 application.yml 配置路由,但是当我尝试发送来自端点的数据我只是挂在 Hystrix Dashboard “Loading ...”上,在教程中效果很好...

hystrix.stream 运行良好,将他放在 Histrix 仪表板中,只显示“正在加载”

我尝试了另一个教程,但问题再次出现!

Maven 依赖项

spring-cloud-starter-netflix-eureka-client
spring-cloud-starter-config
lombok
spring-boot-starter-data-jpa
spring-boot-starter-web
spring-cloud-starter-hystrix:2.7.3.RELEASE
<spring-cloud.version>Hoxton.SR10</spring-cloud.version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

application.yml

spring:
  application:
    name: API-GATEWAY
  cloud:
    gateway:
      routes:
        - id: USER-SERVICE
          uri: lb://USER-SERVICE
          predicates:
            - Path=/user/**
          filters:
            - name: CircuitBreaker
              args:
                name: USER-SERVICE
                fallbackuri: forward:/userServiceFallBack
        - id: DEPARTMENT-SERVICE
          uri: lb://DEPARTMENT-SERVICE
          predicates:
            - Path=/department/**
          filters:
            - name: CircuitBreaker
              args:
                name: DEPARTMENT-SERVICE
                fallbackuri: forward:/departmentServiceFallBack


@Bean
@LoadBalanced
public RestTemplate restTemplate(){
    return new RestTemplate();
}

如果使用@EnableCircuitBreaker 效果很好,问题是使用application.yml 配置spring cloud 路由?

【问题讨论】:

    标签: spring-cloud spring-cloud-netflix hystrix spring-cloud-gateway


    【解决方案1】:

    解决方案很简单,API-GATEWAY,其中 hystrix.stream 用于端口 8789,以及 USER-SERVICE 在端口 9001 上,因此您需要将 API-GATEWAY 端口与用户的端点一起使用来处理指标。

    API-GATEWAY port: 8789
    USER-SERVICE port: 9001
    

    问题:

    API-GATEWAY - http://localhost:8789/acturator/hystrix.stream
    USER-SERVICE save user - http://localhost:9001/user/ 
    

    解决方案:

    API-GATEWAY - http://localhost:8789/acturator/hystrix.stream
    USER-SERVICE save user - http://localhost:8789/user/ 
    

    指标现在运行良好,Hystrix Dashboard 可以正常运行。

    【讨论】:

      猜你喜欢
      • 2018-10-05
      • 2021-11-19
      • 2021-03-27
      • 2020-04-01
      • 2017-08-22
      • 2019-08-03
      • 2019-03-31
      • 2019-01-21
      • 1970-01-01
      相关资源
      最近更新 更多