Details
Description
I don't understand the intent of the following code in Queue.doPageIn() and in rev 818147 it was causing delivery to the consumer to get hung (temporarily until message expiration check kickstarts it again). See the commented out lines of code that determine how many messages to attempt to page in.
private List<QueueMessageReference> doPageIn(boolean force) throws Exception { List<QueueMessageReference> result = null; List<QueueMessageReference> resultList = null; synchronized(dispatchMutex) { //WHAT IS THIS DOING? //int toPageIn = getMaxPageSize() + Math.max(0, (int)destinationStatistics.getInflight().getCount()) -pagedInMessages.size(); //DOES THIS MAKE MORE SENSE: int toPageIn = Math.min(getMaxPageSize(), messages.size()); if (LOG.isDebugEnabled()) { LOG.debug(destination.getPhysicalName() + " toPageIn: " + toPageIn + ", Inflight: " + destinationStatistics.getInflight().getCount() + ", pagedInMessages.size " + pagedInMessages.size()); } //WHAT IS THIS DOING? //toPageIn = Math.max(0, Math.min(toPageIn, getMaxPageSize())); if (isLazyDispatch()&& !force) { // Only page in the minimum number of messages which can be dispatched immediately. toPageIn = Math.min(getConsumerMessageCountBeforeFull(), toPageIn); }
It is definitely possible that I'm just not understanding the intent of the code, but whatever it is, it's not working, and consequently I'm not sure that the subsequent fixes on the branch have eliminated the problem. The attached patch contains both a unit test, that tests several combinations of ack mode, vm cursoring, and delivery mode, as well as version of Queue which should be applied against revirion 818147 – this version has the fix commented out and preserves the buggy behavior