[rabbitmq-discuss] basic.getall?

JD Conley jdc at hive7.com
Thu Nov 26 17:01:17 GMT 2009


> > Absolutely. Don't use basic.get. Instead subscribe to the queue with
> > basic.consume, and if you really want to avoid sending any responses
> to
> > the broker, set the noAck flag to true. That way you don't even have
> to
> > send acks back.
> 
> It's just been pointed out to me that of course with this, you won't
> know when the queue is empty. 

Right, this was my issue with consume. I would like it to return all the
messages as quickly as possible.

Let me explain my current implementation. I'm using this for my Comet-style
long polling application. When the polling client first connects, I empty
its queue quickly and deterministically with a basic.get loop and return the
data. If there is no data I setup an asynchronous acking consumer with a QoS
count of 1. When a message is received, I basic.cancel and then ack. If the
wait period passes without consuming anything I cancel consuming.

> Something like "if you've not received a msg in the
> last 0.5 seconds, try a queue.declare to detect queue-end" may work for
> you, but it's more application logic.

That could work. I guess the big question for me will be... Is it cheaper
(time/cpu wise) to basic.get or setup a consumer. I suppose it would depend
on how many messages are waiting in the queue.

-JD





More information about the rabbitmq-discuss mailing list