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;
}
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;
}
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");
}
}
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);
}
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);
}
Aggregations