Configuration which allows to disable cloud stream?

Nis*_*oru 5 dynamic-loading apache-kafka spring-cloud-stream spring-cloud-stream-binder-kafka

I have a spring boot application which has two functionalities Http requests and kafka Messages handling. I want this application to run in mode which is enabled from application.yml i.e if the user wants to enable it only for http requests then kafka should not be connected.

I could achieve this using normal spring boot kafka plugin by disabling auto configure using the following property at @KafkaListener,

autoStartup="${module.put:false}"

现在我们正在尝试转向云流,我发现通过删除云流和活页夹库来禁用它的唯一方法。有没有更好的方法使用自动配置模式的属性来禁用它,或者是否有任何手动配置选项可用?

awg*_*tek 9

AdminClient我发现我可以通过使用“构建”spring 配置文件连接到(关闭)代理来禁用尝试,然后在 application-build.yml 中排除相关配置:

spring:
  autoconfigure:
    exclude:
      - org.springframework.cloud.stream.config.BindingServiceConfiguration
      - org.springframework.cloud.stream.function.FunctionConfiguration
Run Code Online (Sandbox Code Playgroud)

这是在 Spring Cloud Stream 3.1.3 上测试的。

  • 我已经广泛寻找这个答案,这正是我所需要的。谢谢! (2认同)

Gar*_*ell 0

Spring Cloud Stream 绑定也有autoStartup属性。

https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.4.RELEASE/reference/html/spring-cloud-stream.html#_consumer_properties

自动启动

指示该消费者是否需要自动启动

默认值:true。