0

Assuming that I like 100000 events on my rabbitmq queue, what is the best way to limit a system to handle them in series vs trying to consume all at once?

I'm trying several options, however, the machine freezes trying to handle them all at once.

andresmijares
  • 3,658
  • 4
  • 34
  • 40

2 Answers2

1

You can do ( assuming you're using amqplib)

channel.get('queueName', (err, msgOrFalse) => {
    if (err) { 
        // Handle err
    } else if (msgOrFalse) {
       // Handle message
    }
};

This gets messages one by one, so it's not all at once. You need to call repeatedly of course.

Terry Lennox
  • 29,471
  • 5
  • 28
  • 40
1

I've found my answer, I just need to use prefetch to ensure that I can handle n number of values at once.

andresmijares
  • 3,658
  • 4
  • 34
  • 40
  • That makes sense, you can limit the number of unacknowledged messages in the queue. And presumably this limits the load on the client machine. – Terry Lennox Jan 28 '18 at 21:27