如何在处理 10 条消息后停止 Rabbitmq Consumer?
How to stop Rabbitmq Consumer after processing 10 messages?
我是 运行 crontab 的消费者,它一条一条地处理所有消息,有没有办法只消费 10 或 20 条消息,然后停止消费。
因此下一次 cron 将调用消费者,同样的过程将再次发生。
您可以使用同步 basic.get
方法。将其包装在 for loop
中或添加某种计数器。一旦您达到所需的数量,就可以使用该应用程序。
This method provides a direct access to the messages in a queue using
a synchronous dialogue that is designed for specific types of
application where synchronous functionality is more important than
performance.
我是 运行 crontab 的消费者,它一条一条地处理所有消息,有没有办法只消费 10 或 20 条消息,然后停止消费。
因此下一次 cron 将调用消费者,同样的过程将再次发生。
您可以使用同步 basic.get
方法。将其包装在 for loop
中或添加某种计数器。一旦您达到所需的数量,就可以使用该应用程序。
This method provides a direct access to the messages in a queue using a synchronous dialogue that is designed for specific types of application where synchronous functionality is more important than performance.