On 07/12/2012 03:36 AM, Zhihua Che wrote:
hi,
I got confused with the term of 'capacity' of the sender and receiver.
Essentially 'capacity' restricts the number of 'buffered' messages. In
the case of the sender, this is messages that have been sent but not yet
confirmed by the broker. In the case of the receiver this is the number
of messages the broker can pre-emptively send to the client - what is
often known as 'prefetch', i.e. messages send by the broker before the
application has actually fetched them, in anticipation of- and in order
to speed up- subsequent fetches.
In my app, I create a queue and a sender and a receiver bound with it.
I also set both the capacity of the sender and receiver as 100.
Through qpid-tool, I find that, every time the receiver receives
one message from the queue, a field named 'acquires' of the queue is
increased by one.
Right, that indicates the broker allocating a message to the consumer.
When the 'acquires' number reaches the 100, my app cannot get
message from the queue any more.
What do you mean here? Certainly that number should not go up further
without the receiver calling fetch(), but the receiver should certainly
be able to fetch() more messages. The capacity 'window' is moved as
messages sent by the broker are handed off to the application in
response to fetch() calls.
So, what does the term 'capacity' and the field 'acquires' mean?
Hopefully the description of capacity above will make sense. The
'acquires' stat in management tracks the number of message
'allocations'. For competing consumers, each message is given to only
one consumer - the consumer is considered to have 'acquired' the message.
I noticed that, in qpid-tool, another field 'release' which is
actually above 'acquires' is always 0, is it right?
Yes, unless you either release messages explicitly (through
Session::release()) or end a session without acknowledging messages,
there will be no released messages.
Releasing a message is a mechanism for allowing a message acquired by
one consumer to be returned to the available state and re-acquired
(potentially by another consumer).
As for my code, I use c++ client and qpid::messaging api. I send
the message using sender.send(msg, true), and fetch message with
fetch(msg, Duration::IMMEDIATE), and acknowledge by call
session.acknowledge();
If sending synchronously (i.e. specifying true for the second parameter
to send()), the senders capacity is of no real significance as you are
blocking until that send has completed. (In effect the used capacity
will never be greater than 1).
If you are finding that you stop being able to fetch() messages even
when there are some available on the queue, please provide a bit more
detail on the receiving application, ideally a reproducer.
Hope this helps...
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]