use of org.apache.qpid.server.protocol.v0_8.MessageMetaData in project qpid-broker-j by apache.
the class MessageMetaDataFactoryTest method createTestMessageMetaData.
private MessageMetaData createTestMessageMetaData() {
final MessagePublishInfo publishBody = new MessagePublishInfo(_exchange, false, false, _routingKey);
final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
props.setContentType(CONTENT_TYPE);
final ContentHeaderBody contentHeaderBody = new ContentHeaderBody(props);
return new MessageMetaData(publishBody, contentHeaderBody, _arrivalTime);
}
use of org.apache.qpid.server.protocol.v0_8.MessageMetaData in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_1_0Test method createTestMessage.
private AMQMessage createTestMessage(final BasicContentHeaderProperties basicContentHeaderProperties, final byte[] content, final long arrivalTime) {
final ContentHeaderBody contentHeaderBody = mock(ContentHeaderBody.class);
when(contentHeaderBody.getProperties()).thenReturn(basicContentHeaderProperties);
final StoredMessage<MessageMetaData> storedMessage = mock(StoredMessage.class);
when(storedMessage.getMetaData()).thenReturn(new MessageMetaData(new MessagePublishInfo(), contentHeaderBody, arrivalTime));
if (content != null) {
when(storedMessage.getContentSize()).thenReturn(content.length);
when(storedMessage.getContent(0, content.length)).thenReturn(QpidByteBuffer.wrap(content));
} else {
when(storedMessage.getContentSize()).thenReturn(0);
when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
}
return new AMQMessage(storedMessage);
}
use of org.apache.qpid.server.protocol.v0_8.MessageMetaData in project qpid-broker-j by apache.
the class ReferenceCountingTest method testMessageGetsRemoved.
/**
* Check that when the reference count is decremented the message removes itself from the store
*/
public void testMessageGetsRemoved() throws QpidException {
ContentHeaderBody chb = createPersistentContentHeader();
MessagePublishInfo info = new MessagePublishInfo(null, false, false, null);
final MessageMetaData mmd = new MessageMetaData(info, chb);
StoredMessage storedMessage = _store.addMessage(mmd).allContentAdded();
Transaction txn = _store.newTransaction();
txn.enqueueMessage(createTransactionLogResource("dummyQ"), createEnqueueableMessage(storedMessage));
txn.commitTran();
AMQMessage message = new AMQMessage(storedMessage);
MessageReference ref = message.newReference();
assertEquals(1, getStoreMessageCount());
ref.release();
assertEquals(0, getStoreMessageCount());
}
use of org.apache.qpid.server.protocol.v0_8.MessageMetaData in project qpid-broker-j by apache.
the class ReferenceCountingTest method testMessageRemains.
public void testMessageRemains() throws QpidException {
MessagePublishInfo info = new MessagePublishInfo(null, false, false, null);
final ContentHeaderBody chb = createPersistentContentHeader();
final MessageMetaData mmd = new MessageMetaData(info, chb);
StoredMessage storedMessage = _store.addMessage(mmd).allContentAdded();
Transaction txn = _store.newTransaction();
txn.enqueueMessage(createTransactionLogResource("dummyQ"), createEnqueueableMessage(storedMessage));
txn.commitTran();
AMQMessage message = new AMQMessage(storedMessage);
MessageReference ref = message.newReference();
assertEquals(1, getStoreMessageCount());
MessageReference ref2 = message.newReference();
ref.release();
assertEquals(1, getStoreMessageCount());
}
use of org.apache.qpid.server.protocol.v0_8.MessageMetaData in project qpid-broker-j by apache.
the class MessageConverter_0_10_to_0_8 method convertToStoredMessage.
private StoredMessage<MessageMetaData> convertToStoredMessage(final MessageTransferMessage message, NamedAddressSpace addressSpace) {
final MessageMetaData metaData = convertMetaData(message, addressSpace);
final int metadataSize = metaData.getStorableSize();
return new StoredMessage<org.apache.qpid.server.protocol.v0_8.MessageMetaData>() {
@Override
public MessageMetaData getMetaData() {
return metaData;
}
@Override
public long getMessageNumber() {
return message.getMessageNumber();
}
@Override
public QpidByteBuffer getContent(final int offset, final int length) {
return message.getContent(offset, length);
}
@Override
public int getContentSize() {
return metaData.getContentSize();
}
@Override
public int getMetadataSize() {
return metadataSize;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
@Override
public boolean isInMemory() {
return true;
}
@Override
public boolean flowToDisk() {
return false;
}
@Override
public void reallocate() {
}
};
}
Aggregations