public synchronized void delete(MessageIdentity messageID, MessageAck ack) throws JMSException {
boolean found = false;
QueueListEntry entry = deliveredMessages.getFirstEntry();
while (entry != null) {
MessageIdentity identity = (MessageIdentity) entry.getElement();
if (messageID.equals(identity)) {
deliveredMessages.remove(entry);
// lets used the cached identity as it has the sequence number
// attached to it
messageStore.removeMessage(identity, ack);
found = true;
break;
}
entry = deliveredMessages.getNextEntry(entry);
}
if (!found) {
// maybe the messages have not been delivered yet
// as we are recovering from a previous transaction log
entry = messagesToBeDelivered.getFirstEntry();
while (entry != null) {
MessageIdentity identity = (MessageIdentity) entry.getElement();
if (messageID.equals(identity)) {
messagesToBeDelivered.remove(entry);
// lets used the cached identity as it has the sequence number
// attached to it