Search in sources :

Example 11 with ContentHeaderBody

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

the class ProtocolOutputConverterImpl method writeReturn.

@Override
public void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource message, int channelId, int replyCode, AMQShortString replyText) {
    AMQBody returnFrame = createEncodedReturnFrame(messagePublishInfo, replyCode, replyText);
    writeMessageDelivery(message, header, channelId, returnFrame);
}
Also used : AMQBody(org.apache.qpid.server.protocol.v0_8.transport.AMQBody)

Example 12 with ContentHeaderBody

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

the class ProtocolOutputConverterImpl method writeMessageDeliveryUnchanged.

private void writeMessageDeliveryUnchanged(MessageContentSource content, int channelId, AMQBody deliverBody, ContentHeaderBody contentHeaderBody, int bodySize) {
    if (bodySize == 0) {
        SmallCompositeAMQBodyBlock compositeBlock = new SmallCompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody);
        writeFrame(compositeBlock);
    } else {
        int maxBodySize = (int) _connection.getMaxFrameSize() - AMQFrame.getFrameOverhead();
        int capacity = bodySize > maxBodySize ? maxBodySize : bodySize;
        int writtenSize = capacity;
        AMQBody firstContentBody = new MessageContentSourceBody(content, 0, capacity);
        CompositeAMQBodyBlock compositeBlock = new CompositeAMQBodyBlock(channelId, deliverBody, contentHeaderBody, firstContentBody);
        writeFrame(compositeBlock);
        while (writtenSize < bodySize) {
            capacity = bodySize - writtenSize > maxBodySize ? maxBodySize : bodySize - writtenSize;
            AMQBody body = new MessageContentSourceBody(content, writtenSize, capacity);
            writtenSize += capacity;
            writeFrame(new AMQFrame(channelId, body));
        }
    }
}
Also used : AMQBody(org.apache.qpid.server.protocol.v0_8.transport.AMQBody) AMQFrame(org.apache.qpid.server.protocol.v0_8.transport.AMQFrame)

Example 13 with ContentHeaderBody

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

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

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