Search in sources :

Example 6 with MessageMetaData

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);
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 7 with MessageMetaData

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);
}
Also used : MessageMetaData(org.apache.qpid.server.protocol.v0_8.MessageMetaData) MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 8 with MessageMetaData

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());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) StoredMessage(org.apache.qpid.server.store.StoredMessage) Transaction(org.apache.qpid.server.store.Transaction) MessageReference(org.apache.qpid.server.message.MessageReference)

Example 9 with MessageMetaData

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());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) StoredMessage(org.apache.qpid.server.store.StoredMessage) Transaction(org.apache.qpid.server.store.Transaction) MessageReference(org.apache.qpid.server.message.MessageReference)

Example 10 with MessageMetaData

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() {
        }
    };
}
Also used : MessageMetaData(org.apache.qpid.server.protocol.v0_8.MessageMetaData) StoredMessage(org.apache.qpid.server.store.StoredMessage)

Aggregations

ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)10 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)10 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)6 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)4 StoredMessage (org.apache.qpid.server.store.StoredMessage)4 LinkedHashMap (java.util.LinkedHashMap)2 MessageReference (org.apache.qpid.server.message.MessageReference)2 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)2 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)2 Transaction (org.apache.qpid.server.store.Transaction)2 BufferUnderflowException (java.nio.BufferUnderflowException)1 Date (java.util.Date)1 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)1 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)1 FieldTable (org.apache.qpid.server.protocol.v0_8.FieldTable)1 ConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.ConvertedContentAndMimeType)1 MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType)1 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)1 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1