如何在 kafka 主题/分区中找不到更多消息 &仅在写入主题后阅读 [英] How to find no more messages in kafka topic/partition & reading only after writing to topic is done

查看:36
本文介绍了如何在 kafka 主题/分区中找不到更多消息 &仅在写入主题后阅读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Spring Boot 版本 1.5.4.RELEASE &spring Kafka 版本 1.3.8.RELEASE.

I'm using Spring boot version 1.5.4.RELEASE & spring Kafka version 1.3.8.RELEASE.

一些一般性问题

  1. 有没有办法在主题/分区中找到没有更多消息消费者
  2. 如何启动消费者以开始消费消息制作人写完后才讨论话题?

推荐答案

Spring Boot 1.5 生命周期结束,不再受支持;当前版本是2.2.5.

Spring Boot 1.5 is end of life and no longer supported; the current version is 2.2.5.

适用于 Apache Kafka 的 Spring 的最新 1.3.x 版本是 1.3.10.它只会支持到今年年底.

The latest 1.3.x version of Spring for Apache Kafka is 1.3.10. It will only be supported through the end of this year.

您应该计划升级.

您可以使用 KafkaListenerEndpointRegistry bean 启动和停止容器;将容器工厂的 autoStartup 设置为 false.

You can start and stop containers using the KafkaListenerEndpointRegistry bean; set autoStartup to false on the container factory.

参见检测空闲和无响应的消费者.

虽然高效,但异步消费者的一个问题是检测它们何时空闲 - 如果一段时间内没有消息到达,用户可能希望采取一些措施.

While efficient, one problem with asynchronous consumers is detecting when they are idle - users might want to take some action if no messages arrive for some period of time.

您可以将侦听器容器配置为在一段时间没有消息传递时发布 ListenerContainerIdleEvent.当容器空闲时,将每 idleEventInterval 毫秒发布一个事件.

You can configure the listener container to publish a ListenerContainerIdleEvent when some time passes with no message delivery. While the container is idle, an event will be published every idleEventInterval milliseconds.

...

这篇关于如何在 kafka 主题/分区中找不到更多消息 &仅在写入主题后阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆