[
https://issues.apache.org/jira/browse/QPIDJMS-86?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14628446#comment-14628446
]
Alex Plischke commented on QPIDJMS-86:
--------------------------------------
Hi Robbie,
I did some more debugging in qpid (with prefetch 0 on client side only this
time). Looks like this is how it plays out:
1. Qpid starts off with a prefetch of 0. ActiveMQ lists the same value of 0, as
specified by the client.
2. Qpid checks if there are any messages in its internal message queue. The
internal queue is empty at this moment, thus AmqpConsumer sets the credit to 1.
{noformat}
public void pull(long timeout) {
if (resource.getPrefetchSize() == 0 && getEndpoint().getCredit() == 0) {
// expand the credit window by one.
getEndpoint().flow(1);
}
}
{noformat}
3. ActiveMQ now lists the prefetch as 1 and therefore also pushes a message to
the client.
4. Prefetch on client side will now always remain as 1 and never go back to 0,
as qpid always continues to set the flow to 1 when there are no messages but
never to 0 when there ARE messages in the internal queue.
The above mentioned code only ever sets the credit to 1 (when prefetch is 0),
but never ever back to 0 again.
So, the bug is actually that when setting the prefetch size to 0, qpid behaves
almost exactly as having the prefetch size set to 1.
> AMQP 1.0 prefetch policy set to 0 by the broker results in no messages
> processed
> --------------------------------------------------------------------------------
>
> Key: QPIDJMS-86
> URL: https://issues.apache.org/jira/browse/QPIDJMS-86
> Project: Qpid JMS
> Issue Type: Bug
> Components: qpid-jms-client
> Affects Versions: 0.3.0
> Reporter: Alex Plischke
> Attachments: Screen Shot 2015-07-15 at 9.37.24 AM.png
>
>
> My broker's default prefetch policy is set to 0 (using ActiveMQ).
> When my queue consumer connects to the broker, the broker reports that the
> consumer has indeed a prefetch of 0.
> The qpid client however, just uses the defaults defined in the
> JmsPrefetchPolicy class (ergo, 1000 for the queue).
> So when the qpid client tries to decide whether it needs to poll or not in
> JmsMessageConsumer...
> {noformat}
> protected void sendPullCommand(long timeout) throws JMSException {
> if (messageQueue.isEmpty() && (getPrefetchSize() == 0 ||
> isBrowser())) {
> connection.pull(getConsumerId(), timeout);
> }
> }
> {noformat}
> ... the if condition will be false, since the prefetch size returned here is
> 1000. Qpid will therefore not poll and the broker not push either, resulting
> in no messages processed.
> My current workaround is that I have to set the prefetch size on the client
> as well.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]