}
MessageReference ref;
Consumer handledconsumer = null;
synchronized (this)
{
// Need to do these checks inside the synchronized
if (paused || consumerList.isEmpty())
{
return;
}
if (messageReferences.size() == 0)
{
break;
}
if (endPos < 0 || consumersChanged)
{
consumersChanged = false;
size = consumerList.size();
endPos = pos -1;
if (endPos < 0)
{
endPos = size -1;
noDelivery = 0;
}
}
ConsumerHolder holder = consumerList.get(pos);
Consumer consumer = holder.consumer;
if (holder.iter == null)
{
holder.iter = messageReferences.iterator();
}
if (holder.iter.hasNext())
{
ref = holder.iter.next();
}
else
{
ref = null;
}
if (ref == null)
{
noDelivery++;
}
else
{
if (checkExpired(ref))
{
if (isTrace)
{
log.trace("Reference " + ref + " being expired");
}
holder.iter.remove();
refRemoved(ref);
handled++;
continue;
}
Consumer groupConsumer = null;
if (isTrace)
{
log.trace("Queue " + this.getName() + " is delivering reference " + ref);
}