On 12/10/2009 08:18 PM, Robert Borkowski wrote:
Hello,

Would anyone have pointers on how to get the ruby client to pull a single
message off a queue with no prefetch?
If I have a queue with many items in it and I start connecting a few
competing consumers, I'd like to prevent the first client from prefetching
5000 items...

You can use the message_flow command to set the credit (this is done by the start() method on your incoming queue in the hello world example, and there it is set to infinite credit). You can also then issue a message_flush, which when it returns (in synchronous operation) implies that any message that was on the queue has been delivered to you.

E.g. something like

ssn.message_subscribe(:destination => "d", :queue => "test-queue")
incoming = ssn.incoming("d")
ssn.message_set_flow_mode("d", ssn.message_flow_mode.credit)
ssn.message_flow("d", ssn.message_credit_unit.message, 1)
ssn.message_flow("d", ssn.message_credit_unit.byte, 0xFFFFFFFF)
ssn.message_flush("d")
p incoming.get()

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to