如何在 kafka topic/partition 中找到更多消息并仅在写入主题完成后阅读

How to find no more messages in kafka topic/partition & reading only after writing to topic is done

我正在使用 Spring 启动版本 1.5.4.RELEASE & spring Kafka 版本 1.3.8.RELEASE.

一些通用问题

  1. 有没有办法在topic/partition中找出更多的消息 消费者
  2. 如何让消费者开始消费来自 只有在制作人写完后才话题?

Spring Boot 1.5 已停产,不再受支持;当前版本是 2.2.5.

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

您应该计划升级。

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

参见Detecting Idle and Non-Responsive Consumers

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.

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.

...