简体   繁体   English

如何暂停消费者在Spring云流中消费消息

[英]how to pause consumers from consuming messages in spring cloud stream

I ran into situation where I want to pause consumers to stop consuming messages through spring boot application and messages should not be lost from queue, I am using amqp and spring cloud stream. 我遇到了一些情况,我希望暂停消费者停止通过Spring启动应用程序消费消息,消息不应该从队列中丢失,我正在使用amqp和spring cloud stream。

https://github.com/spring-cloud/spring-cloud-stream/blob/master/docs/src/main/asciidoc/spring-cloud-stream.adoc#binding_visualization_control this states only kafka has this option. https://github.com/spring-cloud/spring-cloud-stream/blob/master/docs/src/main/asciidoc/spring-cloud-stream.adoc#binding_visualization_control这表明只有kafka有此选项。

Can I do something to fix this for rabbit-mq binder? 我可以为Rabbit-mq活页夹做些什么来解决这个问题吗?

Pause is required for Kafka because if you stop() the container, the broker will rebalance and give the partitions to another instance. Kafka需要暂停,因为如果你stop()容器,代理将重新平衡并将分区提供给另一个实例。 With RabbitMQ, the queue remains when the container is stop() ped so the issue doesn't arise there (as long as you specify a group ). 使用RabbitMQ,当容器stop()时,队列仍然存在,因此不会出现问题(只要您指定一个group )。

You can't stop() the container for an anonymous consumer (no group ) because such consumers use an auto-delete queue. 您无法stop()匿名使用者(无group stop()的容器,因为此类使用者使用自动删除队列。 There is no way to pause such consumers (the AMQP protocol has no such mechanism). 没有办法暂停这样的消费者(AMQP协议没有这样的机制)。

暂无
暂无

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

相关问题 Spring 云 Stream + RabbitMQ - 使用队列中的现有消息 - Spring Cloud Stream + RabbitMQ - Consuming existing messages in queue 使用 Spring Cloud Stream Kafka Binder 批量消费 Kafka 消息及其密钥 - Consuming Kafka messages with its key in batches using Spring Cloud Stream Kafka Binder Spring Cloud 流生成和消费相同的主题 - Spring cloud stream producing and consuming the same topic 如何将 spring.cloud.stream.kafka.bindings 配置属性应用于所有消费者 - How to apply spring.cloud.stream.kafka.bindings configuration property to all consumers 如何从spring cloud stream app starter源生成的kafka消息中删除内容类型标头 - How to remove the content type header from kafka messages produced by the spring cloud stream app starter sources 为什么我的 spring 云 stream 配置会创建多个 kafka 消费者 - Why is my spring cloud stream config creating multiple kafka consumers 如何使用 Spring Cloud Spring Boot 3.x Stream 4.x 生产者和消费者关联记录器中的跟踪信息 - How to instrument Spring Boot 3.x with Spring Cloud Stream 4.x producers and consumers to correlate tracing information in loggers Spring Cloud Stream并批量发送消息以排队 - Spring Cloud Stream and sending messages to queue in batches Spring Cloud Stream:@StreamListener处理消息两次 - Spring Cloud Stream: @StreamListener processing messages twice 如何在 spring 集成中推迟消息的消耗 - How to postpone consuming of messages in spring integration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM