public int getContent(long messageId, int offset, ByteBuffer dst) throws AMQStoreException
{
DatabaseEntry contentKeyEntry = new DatabaseEntry();
//Start from 0 offset and search for the starting chunk.
MessageContentKey_5 mck = new MessageContentKey_5(messageId, 0);
TupleBinding<MessageContentKey> contentKeyTupleBinding = new MessageContentKeyTB_5();
contentKeyTupleBinding.objectToEntry(mck, contentKeyEntry);
DatabaseEntry value = new DatabaseEntry();
TupleBinding<ByteBuffer> contentTupleBinding = new ContentTB();
if (_log.isDebugEnabled())
{
_log.debug("Message Id: " + messageId + " Getting content body from offset: " + offset);
}
int written = 0;
int seenSoFar = 0;
Cursor cursor = null;
try
{
cursor = _messageContentDb.openCursor(null, null);
OperationStatus status = cursor.getSearchKeyRange(contentKeyEntry, value, LockMode.READ_UNCOMMITTED);
while (status == OperationStatus.SUCCESS)
{
mck = (MessageContentKey_5) contentKeyTupleBinding.entryToObject(contentKeyEntry);
long id = mck.getMessageId();
if(id != messageId)
{
//we have exhausted all chunks for this message id, break
break;
}
int offsetInMessage = mck.getOffset();
ByteBuffer buf = (ByteBuffer) contentTupleBinding.entryToObject(value);
final int size = (int) buf.limit();
seenSoFar += size;