Search in sources :

Example 16 with ContentHeaderBody

use of org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody in project qpid-broker-j by apache.

the class ReferenceCountingTest method createPersistentContentHeader.

private ContentHeaderBody createPersistentContentHeader() {
    BasicContentHeaderProperties bchp = new BasicContentHeaderProperties();
    bchp.setDeliveryMode((byte) 2);
    ContentHeaderBody chb = new ContentHeaderBody(bchp);
    return chb;
}
Also used : ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 17 with ContentHeaderBody

use of org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody 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 18 with ContentHeaderBody

use of org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody in project qpid-broker-j by apache.

the class MessageConverter_0_10_to_0_8 method convertContentHeaderBody.

private ContentHeaderBody convertContentHeaderBody(MessageTransferMessage message, NamedAddressSpace addressSpace) {
    BasicContentHeaderProperties props = convertContentHeaderProperties(message, addressSpace);
    ContentHeaderBody chb = new ContentHeaderBody(props);
    chb.setBodySize(message.getSize());
    return chb;
}
Also used : ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 19 with ContentHeaderBody

use of org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody in project qpid-broker-j by apache.

the class PropertyConverter_0_8_to_0_10Test 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 20 with ContentHeaderBody

use of org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody in project qpid-broker-j by apache.

the class MessageFormat_0_9_1 method convertToMessageFormat.

@Override
public QpidByteBuffer convertToMessageFormat(final AMQMessage message) {
    final MessagePublishInfo messagePublishInfo = message.getMessagePublishInfo();
    final ContentHeaderBody contentHeaderBody = message.getContentHeaderBody();
    AMQShortString exchange = messagePublishInfo.getExchange();
    AMQShortString routingKey = messagePublishInfo.getRoutingKey();
    int length = contentHeaderBody.getSize() + (exchange == null ? 0 : exchange.length()) + (routingKey == null ? 0 : routingKey.length()) + 3;
    try (QpidByteBuffer headerBuf = QpidByteBuffer.allocateDirect(length);
        QpidByteBuffer content = message.getContent()) {
        EncodingUtils.writeShortStringBytes(headerBuf, exchange);
        EncodingUtils.writeShortStringBytes(headerBuf, routingKey);
        byte flags = messagePublishInfo.isMandatory() ? (byte) 0 : MANDATORY_MASK;
        if (messagePublishInfo.isImmediate()) {
            flags |= IMMEDIATE_MASK;
        }
        headerBuf.put(flags);
        headerBuf.flip();
        contentHeaderBody.writePayload(headerBuf);
        return QpidByteBuffer.concatenate(headerBuf, content);
    }
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Aggregations

ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)23 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)13 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)11 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)6 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)5 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)5 Test (org.junit.Test)5 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)4 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)4 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)4 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)4 HashMap (java.util.HashMap)3 AMQBody (org.apache.qpid.server.protocol.v0_8.transport.AMQBody)3 AMQFrame (org.apache.qpid.server.protocol.v0_8.transport.AMQFrame)3 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)3 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 BasicQosOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody)2