如何从独立涡轮流应用程序收集涡轮流

时间:2018-08-29 08:40:10

标签: spring spring-cloud spring-cloud-stream spring-cloud-netflix

类似于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 的源代码时,发现TurbineControllerFlux暴露在根'/'端点上。

但是当我尝试在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中,但不存在在我的客户端应用中,当我在 spring-cloud-starter-netflix-hystrix spring-cloud-netflix-hystrix-stream 组合中使用时客户端应用程序,效果很好。

2 个答案:

答案 0 :(得分:1)

@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-streamspring-cloud-starter-stream-*添加一个依赖项。

在客户端的application.properties / application.yml文件和涡轮流应用程序上添加Rabbitmq(在我的情况下)配置:

spring:
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest

希望这会有所帮助。

答案 1 :(得分:0)

您应该在客户端应用程序项目上设置属性:spring.cloud.stream.bindings.hystrixStreamOutput.destination = springCloudHystrixStream

相关问题