简体   繁体   中英

How to stop one micro service from consuming the message from Message queue-RabbitMQ

Please help me in this scenario

Suppose there are multiple micro service consuming the messages from rabbitmq But I want to stop for sometime one microservice to consume the message. 1.How will I achieve that?

Real life based scenario of above Suppose I want to add new messaging vendor(for ex otp sending to mobile) and without letting it know to my previous vendor I want to check whether the new vendor is capable of delivering that load. in that case I want without changing the code at previous vendor side and without changing the queues name How we can achieve that? Please help

to stop a consumer is enough to use channel.basicCancel :

for example:

String consumerTag = channel.basicConsume("queue3", consumer);
........ {cosumer messages}

then wen you need to stop it:

channel.basicCancel(consumerTag)

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