1

我有一个 Spring Boot 应用程序,它有两个功能 Http 请求和 kafka 消息处理。我希望此应用程序以从 application.yml 启用的模式运行,即如果用户只想为 http 请求启用它,则不应连接 kafka。

我可以通过使用@KafkaListener 的以下属性禁用自动配置,使用普通的 spring boot kafka 插件来实现这一点,

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

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

4

2 回答 2

0

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

spring:
  autoconfigure:
    exclude:
      - org.springframework.cloud.stream.config.BindingServiceConfiguration
      - org.springframework.cloud.stream.function.FunctionConfiguration

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

于 2021-12-14T23:23:34.920 回答
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

自动启动

如果此消费者需要自动启动,则发出信号

默认值:真。

于 2020-05-12T13:04:06.503 回答