与this post类似,我创建了另一个基于涡轮流的应用程序来收集来自其他应用程序的hystrix流。
Spring Boot:2.0.4.RELEASE,Spring Cloud:Finchley.SR1
应用程序类:
@SpringBootApplication
@EnableDiscoveryClient
@EnableTurbineStream
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
maven依赖:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
应用程序配置文件是:
server:
port: 8989
spring:
application:
name: hystrix-turbine-stream
management:
endpoints:
web.exposure.include: '*'
当我探索@EanbleTurbineStream的源代码时,发现TurbineController
将Flux
暴露给根'/'endpiont。
但是当我试图在Hystrix仪表板中探索http://localhost:8989时,发现它没有按预期工作。
更新:当我尝试访问涡轮流应用程序时,得到:
curl http://localhost:8989
data:{"type":"ping"}
data:{"type":"ping"}
data:{"type":"ping"}
data:{"type":"ping"}
在应用程序控制台(日志记录)中,有一些日志显示为:
: Registering MessageChannel turbineStreamInput
但是我看不到在我的client app中有一些消息发送到这个频道。
这是sample codes of my turbine stream application
Update2:有用了,我在我的客户端应用程序中使用过时的spring-cloud-starter-netflix-hystrix-stream(存在于v2.0.0M2中,但在最终的RELEASE版本中不存在),当我使用spring-客户端应用程序中的cloud-starter-netflix-hystrix和spring-cloud-netflix-hystrix-stream组合,运行良好。
@Hantsy我们需要更多有关您的失败的详细信息。我有一个正在运行的Spring Boot:2.0.4.RELEASE,Spring Cloud:Finchley.SR1涡轮流应用程序,所以如果您需要进一步说明,我可以提供帮助。
要使@EnableTurbineStream
正常工作,您需要根据此处的文档https://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix.html#_turbine_stream在您的应用中添加以下依赖项
spring-cloud-starter-netflix-turbine-stream
spring-boot-starter-webflux
spring-cloud-stream-binder-rabbit
(任何spring-cloud-stream- *都可以,raabitmq为我工作)
在客户端上,向spring-cloud-netflix-hystrix-stream
和您选择的spring-cloud-starter-stream-*
添加依赖项。
在您的客户端的application.properties
/ application.yml
文件和turb-stream应用程序中添加rabbitmq(在我的情况下)配置:
spring:
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
希望这可以帮助。
您应该在客户端应用程序项目上设置属性:spring.cloud.stream.bindings.hystrixStreamOutput.destination = springCloudHystrixStream