}
//now remove the content data from the store if there is any.
DatabaseEntry contentKeyEntry = new DatabaseEntry();
MessageContentKey_5 mck = new MessageContentKey_5(messageId,0);
TupleBinding<MessageContentKey> contentKeyTupleBinding = new MessageContentKeyTB_5();
contentKeyTupleBinding.objectToEntry(mck, contentKeyEntry);
//Use a partial record for the value to prevent retrieving the
//data itself as we only need the key to identify what to remove.
DatabaseEntry value = new DatabaseEntry();
value.setPartial(0, 0, true);
cursor = _messageContentDb.openCursor(tx, null);
status = cursor.getSearchKeyRange(contentKeyEntry, value, LockMode.RMW);
while (status == OperationStatus.SUCCESS)
{
mck = (MessageContentKey_5) contentKeyTupleBinding.entryToObject(contentKeyEntry);
if(mck.getMessageId() != messageId)
{
//we have exhausted all chunks for this message id, break
break;
}
else
{
status = cursor.delete();
if(status == OperationStatus.NOTFOUND)
{
cursor.close();
cursor = null;
tx.abort();
throw new AMQStoreException("Content chunk offset" + mck.getOffset() + " not found for message " + messageId);
}
if (_log.isDebugEnabled())
{
_log.debug("Deleted content chunk offset " + mck.getOffset() + " for message " + messageId);
}
}
status = cursor.getNext(contentKeyEntry, value, LockMode.RMW);
}