LinkedListIterator<MessageReference> iter = iterator();
try
{
DuplicateIDCache targetDuplicateCache = postOffice.getDuplicateIDCache(toAddress);
while (iter.hasNext())
{
MessageReference ref = iter.next();
if (filter == null || filter.match(ref.getMessage()))
{
boolean ignored = false;
deliveringCount.incrementAndGet();
count++;
if (rejectDuplicates)
{
byte[] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
if (duplicateBytes != null)
{
if (targetDuplicateCache.contains(duplicateBytes))
{
HornetQLogger.LOGGER.messageWithDuplicateID(ref.getMessage().getDuplicateProperty(), toAddress, address, address);
acknowledge(tx, ref);
ignored = true;
}
}
}
if (!ignored)
{
move(toAddress, tx, ref, false, rejectDuplicates);
}
iter.remove();
}
}
List<MessageReference> cancelled = scheduledDeliveryHandler.cancel(filter);
for (MessageReference ref : cancelled)
{
byte[] duplicateBytes = ref.getMessage().getDuplicateIDBytes();
if (duplicateBytes != null)
{
if (targetDuplicateCache.contains(duplicateBytes))
{
HornetQLogger.LOGGER.messageWithDuplicateID(ref.getMessage().getDuplicateProperty(), toAddress, address);
continue;
}
}