Search in sources :

Example 86 with AMQMessage

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

the class ProtocolOutputConverterImpl method createEncodedGetOkBody.

private AMQBody createEncodedGetOkBody(AMQMessage message, InstanceProperties props, long deliveryTag, int queueSize) {
    final AMQShortString exchangeName;
    final AMQShortString routingKey;
    final MessagePublishInfo pb = message.getMessagePublishInfo();
    exchangeName = pb.getExchange();
    routingKey = pb.getRoutingKey();
    final boolean isRedelivered = Boolean.TRUE.equals(props.getProperty(InstanceProperties.Property.REDELIVERED));
    return _connection.getMethodRegistry().createBasicGetOkBody(deliveryTag, isRedelivered, exchangeName, routingKey, queueSize);
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)

Example 87 with AMQMessage

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

the class ProtocolOutputConverterImpl method writeDeliver.

@Override
public long writeDeliver(final AMQMessage msg, final InstanceProperties props, int channelId, long deliveryTag, AMQShortString consumerTag) {
    final boolean isRedelivered = Boolean.TRUE.equals(props.getProperty(InstanceProperties.Property.REDELIVERED));
    AMQBody deliverBody = createEncodedDeliverBody(msg, isRedelivered, deliveryTag, consumerTag);
    return writeMessageDelivery(msg, channelId, deliverBody);
}
Also used : AMQBody(org.apache.qpid.server.protocol.v0_8.transport.AMQBody)

Example 88 with AMQMessage

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

the class AMQMessageMutatorTest method createTestMessage.

private AMQMessage createTestMessage() {
    final BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
    basicContentHeaderProperties.setPriority(TEST_PRIORITY);
    basicContentHeaderProperties.setHeaders(FieldTableFactory.createFieldTable(Collections.singletonMap(TEST_HEADER_NAME, TEST_HEADER_VALUE)));
    basicContentHeaderProperties.setContentType(TEST_CONTENT_TYPE);
    QpidByteBuffer content = QpidByteBuffer.wrap(TEST_CONTENT.getBytes(UTF_8));
    final ContentHeaderBody contentHeader = new ContentHeaderBody(basicContentHeaderProperties, content.remaining());
    final MessagePublishInfo publishInfo = new MessagePublishInfo(AMQShortString.valueOf("testExchange"), true, true, AMQShortString.valueOf("testRoutingKey"));
    final MessageMetaData messageMetaData = new MessageMetaData(publishInfo, contentHeader, System.currentTimeMillis());
    final MessageHandle<MessageMetaData> handle = _messageStore.addMessage(messageMetaData);
    handle.addContent(content);
    return new AMQMessage(handle.allContentAdded());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 89 with AMQMessage

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 testToConversionWhenGlobalAddressIsKnown.

@Test
public void testToConversionWhenGlobalAddressIsKnown() {
    final String globalPrefix = "/testPrefix";
    final String queueName = "testQueue";
    final String globalAddress = globalPrefix + "/" + queueName;
    InternalMessage message = createTestMessage(globalAddress);
    Queue<?> queue = mock(Queue.class);
    when(queue.getName()).thenReturn(queueName);
    doReturn(queue).when(_addressSpace).getAttainedMessageDestination(eq(queueName), anyBoolean());
    when(_addressSpace.getLocalAddress(globalAddress)).thenReturn(queueName);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
    final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
    assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
    assertEquals("Unexpected routing key", queueName, messagePublishInfo.getRoutingKey().toString());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 90 with AMQMessage

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 testToConversionWhenExchangeAndRoutingKeyIsSpecified.

@Test
public void testToConversionWhenExchangeAndRoutingKeyIsSpecified() {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    String to = testExchange + "/" + testRoutingKey;
    InternalMessage message = createTestMessage(to);
    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());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)198 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)176 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)143 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)114 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)78 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)76 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)58 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)57 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)46 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)38 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)33 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)32 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)32 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)26 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)25 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)24 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)17 HashMap (java.util.HashMap)15 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)14 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12