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