Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我喜欢我的 rabbitmq 队列上的 100000 个事件,那么限制系统串联处理它们而不是尝试一次消耗所有事件的最佳方法是什么?
我正在尝试几个选项,但是,机器冻结试图一次处理它们。
您可以这样做(假设您使用的是 amqplib)
channel.get('queueName', (err, msgOrFalse) => { if (err) { // Handle err } else if (msgOrFalse) { // Handle message } };
这会一一获取消息,因此不是一次全部。当然,您需要反复调用。
我找到了答案,我只需要使用它prefetch来确保我可以一次处理 n 个值。
prefetch