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))
{
log.info("Message with duplicate ID " + ref.getMessage().getDuplicateProperty() + " was already set at " + toAddress + ". Move from " + this.address + " being ignored and message removed from " + this.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))
{
log.info("Message with duplicate ID " + ref.getMessage().getDuplicateProperty() + " was already set at " + toAddress + ". Move from " + this.address + " being ignored");
continue;
}
}
deliveringCount.incrementAndGet();