简体   繁体   中英

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.

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.

Can I do something to fix this for rabbit-mq binder?

Pause is required for Kafka because if you stop() the container, the broker will rebalance and give the partitions to another instance. 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 ).

You can't stop() the container for an anonymous consumer (no group ) because such consumers use an auto-delete queue. There is no way to pause such consumers (the AMQP protocol has no such mechanism).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM