简体   繁体   English

Spring Cloud:Hystrix在ping上未显示任何数据

[英]Spring Cloud: Hystrix shows no data on ping

I'm using hystrix in my spring boot application but when i access the /hystrix-stream page there is no data. 我在春季启动应用程序中使用hystrix,但是当我访问/ hystrix-stream页面时,没有数据。 It shows only "ping: ". 它仅显示“ ping:”。 In my pom.xml i've got the following: 在我的pom.xml中,我有以下内容:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-ribbon</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.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

I have enabled Hystrix and HystrixDashboard. 我启用了Hystrix和HystrixDashboard。 Additionally i'm using ribbon in my application. 另外,我在应用程序中使用功能区。 The HystrixCommand looks like this: HystrixCommand看起来像这样:

@HystrixCommand(fallbackMethod = "defaultFallback")
public byte[] doGet() {
    return this.restTemplate.getForObject("http://myInstance/api/v3/ressource",byte[].class);
}

public byte[] defaultFallback() {
    System.out.println("Now doing fallback!");
    return null;
}

When i shut down myInstance there is no fallback called, ribbon shows me only this failure: 当我关闭myInstance时 ,没有回退调用,功能区仅显示此失败:

There was an unexpected error (type=Internal Server Error, status=500).
I/O error on POST request for "http:/myInstance/api/v3/ressource": Connection
refused; nested exception is java.net.ConnectException: Connection refused

Your spring boot application must enable the circuit breaker. 您的Spring Boot应用程序必须启用断路器。

Like the next example: 类似于下一个示例:

@EnableCircuitBreaker
@SpringBootApplication
@EnableDiscoveryClient
@EnableWebMvc
public class ClientManagerApp {

    public static void main(String[] args) {
        SpringApplication.run(ClientManagerApp.class, args);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM