use of org.apache.qpid.server.protocol.v0_8.AMQMessage 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);
}
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class AMQMessageMutator method create.
@Override
public AMQMessage create() {
final long contentSize = _message.getSize();
final QpidByteBuffer content = _message.getContent();
final ContentHeaderBody contentHeader = new ContentHeaderBody(_basicContentHeaderProperties, contentSize);
final MessageMetaData messageMetaData = new MessageMetaData(_message.getMessagePublishInfo(), contentHeader, _message.getArrivalTime());
final MessageHandle<MessageMetaData> handle = _messageStore.addMessage(messageMetaData);
if (content != null) {
handle.addContent(content);
}
return new AMQMessage(handle.allContentAdded(), _message.getConnectionReference());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class ProtocolOutputConverterImpl method createEncodedDeliverBody.
private AMQBody createEncodedDeliverBody(AMQMessage message, boolean isRedelivered, final long deliveryTag, final AMQShortString consumerTag) {
final AMQShortString exchangeName;
final AMQShortString routingKey;
final MessagePublishInfo pb = message.getMessagePublishInfo();
exchangeName = pb.getExchange();
routingKey = pb.getRoutingKey();
return new EncodedDeliveryBody(deliveryTag, routingKey, exchangeName, consumerTag, isRedelivered);
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testConversionWhenToIsUnsetButInitialRoutingKeyIsSet.
@Test
public void testConversionWhenToIsUnsetButInitialRoutingKeyIsSet() {
final String testExchange = "testExchange";
final String testRoutingKey = "testRoutingKey";
InternalMessage message = createTestMessage("");
final String testInitialRoutingAddress = testExchange + "/" + testRoutingKey;
message.setInitialRoutingAddress(testInitialRoutingAddress);
final Exchange exchange = mock(Exchange.class);
when(exchange.getName()).thenReturn(testExchange);
doReturn(exchange).when(_addressSpace).getAttainedMessageDestination(eq(testExchange), anyBoolean());
final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected exchange", testExchange, messagePublishInfo.getExchange().toString());
assertEquals("Unexpected routing key", testRoutingKey, messagePublishInfo.getRoutingKey().toString());
}
use of org.apache.qpid.server.protocol.v0_8.AMQMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testToConversionWhenQueueIsSpecified.
@Test
public void testToConversionWhenQueueIsSpecified() {
final String testQueue = "testQueue";
InternalMessage message = createTestMessage(testQueue);
final Queue queue = mock(Queue.class);
when(queue.getName()).thenReturn(testQueue);
doReturn(queue).when(_addressSpace).getAttainedMessageDestination(eq(testQueue), anyBoolean());
final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
assertEquals("Unexpected routing key", testQueue, messagePublishInfo.getRoutingKey().toString());
}
Aggregations