java Spring云流Kafka消费类应用,AdminClient被无故调用

wqnecbli  于 2023-02-11  发布在  Java
关注(0)|答案(1)|浏览(166)

关于Spring Cloud涧Kafka的小问题。
我有一个非常简单和直接的消费者。它只是消费,不产生消息,主题已经存在,我不需要创建主题。

@SpringBootApplication
public class StreamReactiveConsumerApplication implements CommandLineRunner {

    private static final Logger log = LoggerFactory.getLogger(StreamReactiveConsumerApplication.class);

    public static void main(String... args) {
        new SpringApplicationBuilder(StreamReactiveConsumerApplication.class).web(WebApplicationType.NONE).run(args);
    }

    @Override
    public void run(String... args) throws Exception {
        log.warn("Remember about calling <.subscribe()> at the end of your Consumer<Flux> bean!");
        log.warn("Remember about finishing the span manually before calling subscribe!");
    }

    @Bean
    Consumer<Flux<Message<String>>> channel(Tracer tracer, ObservationRegistry observationRegistry) {
        return flux -> flux.doOnNext(msg -> log.info("<ACCEPTANCE_TEST> <TRACE:{}> Hello from consumer",
                tracer.currentSpan().context().traceId())).subscribe();
    }

}

然而,在应用程序启动时,我看到来自管理客户端的交互,请参见下面的日志:

2023-02-06 10:25:24 [stream-reactive-consumer,,] o.s.i.endpoint.EventDrivenConsumer : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.s.i.c.PublishSubscribeChannel : Channel 'stream-reactive-consumer.errorChannel' has 1 subscriber(s).
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.s.i.endpoint.EventDrivenConsumer : started bean '_org.springframework.integration.errorLogger'
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.s.c.s.binder.DefaultBinderFactory : Creating binder: kafka
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.s.c.s.binder.DefaultBinderFactory : Constructing binder child context for kafka
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.s.c.s.binder.DefaultBinderFactory : Caching the binder: kafka
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.a.k.c.admin.AdminClientConfig : AdminClientConfig values:

[bunch of values...]

2023-02-06 10:25:24 [stream-reactive-consumer,,] o.a.kafka.common.utils.AppInfoParser : Kafka version: 3.3.1
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: e23c59d00e687ff5
2023-02-06 10:25:24 [stream-reactive-consumer,,] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1675650324403

如您所见,应用程序正在调用管理客户端:

2023-02-06 10:25:24 [stream-reactive-consumer,,] o.a.k.c.admin.AdminClientConfig : AdminClientConfig values:

我可以问一下为什么这种依赖管理员的消费者专用应用程序吗?再次,我不生产任何东西,不创造任何主题。
有没有办法消费没有这个管理客户端,请禁用这个管理客户端?
谢谢

brgchamk

brgchamk1#

正如@加里Russell所建议的那样,该错误已修复,并且在仅限消费者使用的应用程序启动时确实不希望看到管理客户端。
在我的情况下,这是由于一对夫妇的事情混合:
1 - How can I configure a Spring Cloud Stream (Kafka) application to autocreate the topics in Confluent Cloud?
spring.cloud.stream.Kafka.binder.autoCreateTopics属性默认设置为true,这将“触发管理客户端”
在我这边,我确实将其设置为false,但由于以下问题:https://github.com/spring-cloud/spring-cloud-stream/issues/2644在本机上运行时,不考虑该属性。
确保属性为false,并按照加里的建议设置断点是正确的解决方案(对他所说的话投了赞成票)

相关问题