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