Hystrix 대시 보드를 처음 사용했습니다. Hystrix로 샘플 애플리케이션을 작성했습니다. Hystrix 차트 (명령 메트릭 스트림)를보고 싶습니다. 그러나 아래 오류가 나타납니다 :스프링 부트의 Hystrix 대시 보드 문제
Circuit: Unable to connect to Command Metric Stream
Thread Pools: Loading...
Maven과 함께 STS를 사용하고 있습니다.
간단한 서버 microservice 응용 프로그램 (봄 부트 웹 포트 8085에서 실행)
이package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
@RestController
@SpringBootApplication
public class BookstoreApplication {
@RequestMapping(value = "/recommended")
public String readingList(){
return "Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)";
}
public static void main(String[] args) {
SpringApplication.run(BookstoreApplication.class, args);
}
}
이
간단한 클라이언트 microservice 응용 프로그램 (봄 부팅 웹 포트 8095에서 실행이) 내가 포함했다 : 아래
사용되는 코드입니다 Hystrix 및 웹과 함께 Hystrix 대시 보드의 의존성 때문에 모든 Hystrix 종속성, 위의 코드를 실행하여 클래스 경로package hello;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
@Service
public class BookService {
private final RestTemplate restTemplate;
public BookService(RestTemplate rest) {
this.restTemplate = rest;
}
@HystrixCommand(fallbackMethod = "reliable")
public String readingList() {
URI uri = URI.create("http://localhost:8090/recommended");
return this.restTemplate.getForObject(uri, String.class);
}
public String reliable() {
return "Cloud Native Java (O'Reilly)";
}
}
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.web.client.RestTemplate;
@EnableHystrixDashboard
@EnableHystrix
@EnableCircuitBreaker
@RestController
@SpringBootApplication
public class ReadingApplication {
@Autowired
private BookService bookService;
@Bean
public RestTemplate rest(RestTemplateBuilder builder) {
return builder.build();
}
@RequestMapping("/to-read")
public String toRead() {
return bookService.readingList();
}
public static void main(String[] args) {
SpringApplication.run(ReadingApplication.class, args);
}
}
에 hystrix가 제대로 작동하고 BooKStoreApplication이 다운되었을 때 fallback 메소드로 넘어갑니다.
두 URL 모두 정상적으로 작동합니다. 일반 케이스 :이 URL http://localhost:8095/hystrix를 호출하려고 할 때
http://localhost:8085/recommended
Output: Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)
http://localhost:8095/to-read
Output: Spring in Action (Manning), Cloud Native Java (O'Reilly), Learning Spring Boot (Packt)
When BookStoreApplication is down (http://localhost:8085/recommended) accessing http://localhost:8095/to-read returns "Cloud Native Java (O'Reilly)" as expected.
을하지만, 나는 Hystrix DashBoard를 페이지를 받고 스트림 값을 요청하고있다.
가 나는 http://localhost:8095/ 또는 http://localhost:8095/to-read를 부여하고, "모니터 스트림"을 클릭하고이 오류로 다음 페이지로 이동됩니다 시도 :
Circuit: Unable to connect to Command Metric Stream
Thread Pools: Loading...