A
A
Alexander2016-10-12 08:13:03
PHP
Alexander, 2016-10-12 08:13:03

RabbitMQ: How to get only part of messages?

In all the examples on the offsite www.rabbitmq.com/getstarted.html , an infinite loop is used to get messages from the queue, i.e. in fact, you need a demon that will constantly spin this cycle. I’ve been working with Rabbit recently, so I’m interested in the question of whether it’s possible to receive messages not all at once, but in batches, for example, 10 pieces each, when accessing the script (without an infinite loop)?
I write in php using the phpAmqpLib library
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-10-12
@sanchez161

1) Use basic_get instead of basic_consume, this thing only gets one message per call, an example of usage is https://github.com/php-amqplib/php-amqplib/blob/ma...
2) Make a counter of received messages and when reaching 10 close the channel.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question