[rabbitmq-discuss] forking and getting or consuming messages

Chris dmagick at gmail.com
Fri Jul 26 06:24:23 BST 2013


Hi,

I'm setting up a system that will have multiple queues. One script 
listens to a 'master' queue and then forks off other scripts to deal 
with the other queues as required.

This all works fine except for a couple of things.

I'm basically doing a
while (queue->get()) {
   do stuff;
}

If the queue is already running and another message goes onto the stack, 
I don't see it until the script runs again. I tried closing the channel 
and then opening it again but that didn't help (it caused a problem in 
amqplib). Any suggestions?

The second problem is that once all the messages are off the stack, the 
script exits. I'd like it to stay open and wait for more messages to 
come in. Is that possible using the queue->get() approach?

I tried changing it to work as a queue consumer (which addressed the 2nd 
problem), but then I only got one message from the queue at a time, I 
had to wait for each message to finish processing before starting the 
next one, so forking off connections didn't work. Should this idea work?

I'm using php-amqplib (https://github.com/tnc/php-amqplib) to talk to 
rabbitmq.

Thanks for any suggestions/comments.

Cheers,
-- 
Postgresql & php tutorials
http://www.designmagick.com/



More information about the rabbitmq-discuss mailing list