简体   繁体   English

如何判断每个消费者是否完成了 Spring Cloud Stream Kafka?

[英]How to tell if every consumer finished in Spring Cloud Stream Kafka?

I'm trying to black-box test a Spring Boot application which is using Spring Cloud Stream Kafka.我正在尝试对使用 Spring Cloud Stream Kafka 的 Spring 引导应用程序进行黑盒测试。 The expected results (in the DB) may differ based on the message processing order.预期结果(在 DB 中)可能因消息处理顺序而异。 How could I reliably tell if one message was processed and I can send in the next?我怎样才能可靠地判断一条消息是否已处理并且我可以发送下一条消息? One important factor is that one message from the test can generate multiple events (messages) within the application.一个重要因素是来自测试的一条消息可以在应用程序内生成多个事件(消息)。

I did the following methods:我做了以下方法:

  • wait fixed amount of time: usually works, but if someone's PC is hot and throttling, it can become flaky, and to be honest this is just ugly等待固定的时间:通常可以,但是如果某人的 PC 很热且节流,它可能会变得不稳定,老实说,这很丑
  • create an aspect to count the method invocations, serve it through a controller, query it multiple times, send the next message when we're "settled": timing of querying matters, unreliable创建一个方面来计算方法调用,通过 controller 提供服务,多次查询,当我们“解决”时发送下一条消息:查询的时间很重要,不可靠
  • periodically check Kafka consumer lag, either from code or by querying actuator, with multiple samples: this is mixture of the above two, sometimes slower than the first but more reliable定期检查 Kafka 消费者滞后,无论是从代码还是通过查询执行器,使用多个样本:这是上述两者的混合,有时比第一个慢但更可靠

Is there any official way of doing this?有没有官方的方法可以做到这一点?

Configure the container to emit ListenerContainerIdleEvent s.将容器配置为发出ListenerContainerIdleEvent

See https://docs.spring.io/spring-kafka/docs/current/reference/html/#idle-containershttps://docs.spring.io/spring-kafka/docs/current/reference/html/#idle-containers

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 春季云流中的Kafka消费者无法启动 - Kafka consumer in spring cloud stream dont start 为什么一个消费者为 Spring Cloud Stream Kafka 创建多个消费者配置? - Why does one consumer create multiple consumer configs for Spring Cloud Stream Kafka? Spring 云 Stream 消费者启动 - Spring Cloud Stream consumer startup Spring Cloud Stream Producer在使用Spring Kafka Consumer时添加了“垃圾”字符 - Spring Cloud Stream Producer adds “junk” characters when using Spring Kafka Consumer Spring 云 stream 在同一应用程序中声明生产者和消费者时不向 Kafka 发送消息 - Spring cloud stream not send message to Kafka when declare producer and consumer in the same application Spring-cloud-stream流Kafka使用者不会使用服务关闭时发送的消息吗? - Will spring-cloud-stream Kafka consumer not consume messages that were sent when the service was down? 带有 kafka 消费者的 Spring Cloud Stream 3.0 在批处理模式下获取列表中的单个记录而不是更多 - Spring Cloud Stream 3.0 with kafka consumer in batch mode fetches single record in list instead of more Spring Cloud Stream (Hoxton) Kafka Producer/Consumer 无法与 EmbeddedKafka 进行集成测试 - Spring Cloud Stream (Hoxton) Kafka Producer / Consumer not working in integration tests with EmbeddedKafka Spring 云 stream 卡夫卡消费者卡在长时间运行的作业和 max.poll.interval.ms 的大值 - Spring cloud stream Kafka consumer stuck with long running job and large value for max.poll.interval.ms 如何使用RMQ和Spring Cloud Stream创建基于分区的使用者 - How to use RMQ and spring cloud stream for creating partition based consumer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM