【问题标题】:How to collect turbine stream from a Standalone Turbine Stream application如何从独立涡轮流应用程序中收集涡轮流
【发布时间】:2019-02-03 23:39:57
【问题描述】:

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 Dashboard 中探索 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-hystrixspring-cloud-netflix-hystrix-stream 组合客户端应用,运行良好。

【问题讨论】:

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


    【解决方案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-stream 和您选择的 spring-cloud-starter-stream-*

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

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

    希望这会有所帮助。

    【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 这对我有用:spring.cloud.stream.bindings.hystrixStreamOutput.destination:turberStreamInput
    猜你喜欢
    • 2023-01-14
    • 1970-01-01
    • 2018-06-19
    • 2012-11-16
    • 1970-01-01
    • 2010-11-10
    • 2013-07-10
    • 1970-01-01
    • 2017-01-14
    相关资源
    最近更新 更多