【发布时间】:2018-12-12 16:44:20
【问题描述】:
我正在尝试为我的 java spring boot 应用程序设置一个 hystrix 仪表板。启动应用程序后,我在控制台中收到代理打开消息,但没有任何反应。
Proxy opening connection to: http://localhost:9083/actuator/hystrix.stream
在仪表板中显示正在加载...并且没有显示任何内容...请参阅底部附加的图片。
此外,当我在浏览器中点击此 url http://localhost:9083/actuator/hystrix.stream 时,不会显示任何数据,只是不断的空 ping。喜欢
平:
平:
平:
...
我所做的代码更改是
@RequestMapping(value = "/elasticsearch/{numberOfInstances}/{name}", method = RequestMethod.GET)
public void ingestMip4DataToES(@PathVariable("numberOfInstances") int numberOfInstances,
@PathVariable("name") String name) {
if(numberOfInstances > 1) {
List<IdentifiableType> identifiableTypes = generateMultipleInstancesOfMip4Data(numberOfInstances, name);
if(!identifiableTypes.isEmpty()) {
dumpBulkMip4DataToES(identifiableTypes);
}
} else {
IdentifiableType identifiableType = generateSingleInstanceOfMip4Data(name);
if(identifiableType != null) {
dumpMip4DataToES(identifiableType);
}
}
}
@HystrixCommand(fallbackMethod = "fallbackForMip4SingleDataGeneration")
private IdentifiableType generateSingleInstanceOfMip4Data(String name) {
String url = GENERATOR_URL + name;
ResponseEntity<IdentifiableType> response = restTemplate.getForEntity(url, IdentifiableType.class);
return response.getBody();
}
private IdentifiableType fallbackForMip4SingleDataGeneration() {
logger.info("Calling fallback method for mip4 data generation as request to service failed.");
return null;
}
在主类中包含必需的注释。
@SpringBootApplication
//@EnableDiscoveryClient
@EnableCircuitBreaker
@EnableHystrixDashboard
public class InsaneMip4ElasticSearchApplication {
public static void main(String[] args) {
SpringApplication.run(InsaneMip4ElasticSearchApplication.class, args);
}
}
资源文件包含以下条目
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.include=hystrix.stream
management.endpoints.jmx.exposure.include=*
management.endpoint.health.show-details=ALWAYS
management.endpoint.shutdown.enabled=true
并且为 pom 文件创建了以下条目
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
【问题讨论】:
-
确保控制达到这个功能
generateSingleInstanceOfMip4Data。如果流程没有通过 HystrixCommand 到达函数一次,您将看不到任何东西 -
对不起,我听不懂你的意思
-
一旦你启动应用程序。这个函数什么时候叫
generateSingleInstanceOfMip4Data?就做什么动作?我是说应该调用这个方法让你在仪表板中看到一些东西。您是否正在执行一些导致调用此函数的操作。如果不这样做。 -
是的,这个函数是从另一个函数调用的,我刚刚编辑了代码供您参考。当我使用请求映射执行映射的 url 时,也没有任何反应。
-
你确定你使用 numberofInstances
标签: java spring spring-boot hystrix