Search in sources :

Example 21 with ContentHeaderBody

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

the class ProtocolOutputConverterImpl method writeMessageDelivery.

private long writeMessageDelivery(MessageContentSource message, ContentHeaderBody contentHeaderBody, int channelId, AMQBody deliverBody) {
    int bodySize = (int) message.getSize();
    boolean msgCompressed = isCompressed(contentHeaderBody);
    DisposableMessageContentSource modifiedContent = null;
    boolean compressionSupported = _connection.isCompressionSupported();
    long length;
    if (msgCompressed && !compressionSupported && (modifiedContent = inflateIfPossible(message)) != null) {
        BasicContentHeaderProperties modifiedProps = new BasicContentHeaderProperties(contentHeaderBody.getProperties());
        modifiedProps.setEncoding((String) null);
        length = writeMessageDeliveryModified(modifiedContent, channelId, deliverBody, modifiedProps);
    } else if (!msgCompressed && compressionSupported && contentHeaderBody.getProperties().getEncoding() == null && bodySize > _connection.getMessageCompressionThreshold() && (modifiedContent = deflateIfPossible(message)) != null) {
        BasicContentHeaderProperties modifiedProps = new BasicContentHeaderProperties(contentHeaderBody.getProperties());
        modifiedProps.setEncoding(GZIP_ENCODING);
        length = writeMessageDeliveryModified(modifiedContent, channelId, deliverBody, modifiedProps);
    } else {
        writeMessageDeliveryUnchanged(message, channelId, deliverBody, contentHeaderBody, bodySize);
        length = bodySize;
    }
    if (modifiedContent != null) {
        modifiedContent.dispose();
    }
    return length;
}
Also used : BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 22 with ContentHeaderBody

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

the class ProtocolOutputConverterImpl method writeMessageDeliveryModified.

private int writeMessageDeliveryModified(final MessageContentSource content, final int channelId, final AMQBody deliverBody, final BasicContentHeaderProperties modifiedProps) {
    final int bodySize = (int) content.getSize();
    ContentHeaderBody modifiedHeaderBody = new ContentHeaderBody(modifiedProps, bodySize);
    writeMessageDeliveryUnchanged(content, channelId, deliverBody, modifiedHeaderBody, bodySize);
    return bodySize;
}
Also used : ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)

Example 23 with ContentHeaderBody

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

the class AMQDecoderTest method testContentHeaderPropertiesFrame.

public void testContentHeaderPropertiesFrame() throws AMQProtocolVersionException, AMQFrameDecodingException, IOException {
    final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
    final FieldTable table = new FieldTable();
    table.setString("hello", "world");
    table.setInteger("1+1=", 2);
    props.setHeaders(table);
    final AMQBody body = new ContentHeaderBody(props);
    AMQFrame frame = new AMQFrame(1, body);
    TestSender sender = new TestSender();
    frame.writePayload(sender);
    ByteBuffer msg = combine(sender.getSentBuffers());
    _decoder.decodeBuffer(msg);
    List<AMQDataBlock> frames = _methodProcessor.getProcessedMethods();
    AMQDataBlock firstFrame = frames.get(0);
    if (firstFrame instanceof AMQFrame) {
        assertEquals(ContentHeaderBody.TYPE, ((AMQFrame) firstFrame).getBodyFrame().getFrameType());
        BasicContentHeaderProperties decodedProps = ((ContentHeaderBody) ((AMQFrame) firstFrame).getBodyFrame()).getProperties();
        final FieldTable headers = decodedProps.getHeaders();
        assertEquals("world", headers.getString("hello"));
    } else {
        fail("decode was not a frame");
    }
}
Also used : AMQDataBlock(org.apache.qpid.server.protocol.v0_8.transport.AMQDataBlock) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) AMQBody(org.apache.qpid.server.protocol.v0_8.transport.AMQBody) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQFrame(org.apache.qpid.server.protocol.v0_8.transport.AMQFrame) ByteBuffer(java.nio.ByteBuffer) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 24 with ContentHeaderBody

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

the class PropertyConverter_v0_8_to_InternalTest 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 : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)

Example 25 with ContentHeaderBody

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

the class BasicInteraction method contentHeader.

public Interaction contentHeader(int contentSize) throws Exception {
    final BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setHeaders(FieldTable.convertToFieldTable(_contentHeaderPropertiesHeaders));
    basicContentHeaderProperties.setContentType(_contentHeaderPropertiesContentType);
    basicContentHeaderProperties.setDeliveryMode(_contentHeaderPropertiesDeliveryMode);
    basicContentHeaderProperties.setPriority(_contentHeaderPropertiesPriority);
    ContentHeaderBody contentHeaderBody = new ContentHeaderBody(basicContentHeaderProperties, contentSize);
    return _interaction.sendPerformative(contentHeaderBody);
}
Also used : ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

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