Search in sources :

Example 21 with ReplyTo

use of org.apache.qpid.server.protocol.v0_10.transport.ReplyTo in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10 method getReplyTo.

private ReplyTo getReplyTo(final NamedAddressSpace addressSpace, final String origReplyTo) {
    DestinationAddress destinationAddress = new DestinationAddress(addressSpace, origReplyTo);
    MessageDestination messageDestination = destinationAddress.getMessageDestination();
    return new ReplyTo(ensureStr8("reply-to[\"exchange\"]", messageDestination instanceof Exchange ? messageDestination.getName() : ""), ensureStr8("reply-to[\"routing-key\"]", messageDestination instanceof Queue ? messageDestination.getName() : destinationAddress.getRoutingKey()));
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) Exchange(org.apache.qpid.server.model.Exchange) MessageDestination(org.apache.qpid.server.message.MessageDestination) Queue(org.apache.qpid.server.model.Queue) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Example 22 with ReplyTo

use of org.apache.qpid.server.protocol.v0_10.transport.ReplyTo in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testReplyToConversionWhenRoutingKeySpecified.

public void testReplyToConversionWhenRoutingKeySpecified() {
    final String routingKey = "test_routing_key";
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setReplyTo(new ReplyTo(null, routingKey));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected reply-to", routingKey, properties.getReplyTo());
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 23 with ReplyTo

use of org.apache.qpid.server.protocol.v0_10.transport.ReplyTo in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testReplyToConversionWhenExchangeSpecified.

public void testReplyToConversionWhenExchangeSpecified() {
    final String exchangeName = "amq.direct";
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setReplyTo(new ReplyTo(exchangeName, null));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected reply-to", exchangeName, properties.getReplyTo());
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 24 with ReplyTo

use of org.apache.qpid.server.protocol.v0_10.transport.ReplyTo in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testReplyToConversionWhenExchangeAndRoutingKeyAreSpecified.

public void testReplyToConversionWhenExchangeAndRoutingKeyAreSpecified() throws IOException {
    final String exchangeName = "testExchnageName";
    final String routingKey = "testRoutingKey";
    final String replyTo = String.format("%s/%s", exchangeName, routingKey);
    final Exchange exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(exchangeName);
    when(_namedAddressSpace.getAttainedMessageDestination(exchangeName)).thenReturn(exchange);
    Properties properties = new Properties();
    properties.setReplyTo(replyTo);
    Message_1_0 message = createTestMessage(properties);
    MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final ReplyTo convertedReplyTo = convertedMessage.getHeader().getMessageProperties().getReplyTo();
    assertEquals("Unexpected exchange", exchangeName, convertedReplyTo.getExchange());
    assertEquals("Unexpected routing key", routingKey, convertedReplyTo.getRoutingKey());
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 25 with ReplyTo

use of org.apache.qpid.server.protocol.v0_10.transport.ReplyTo in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_10Test method testReplyToConversionWhenResultExceeds255.

public void testReplyToConversionWhenResultExceeds255() {
    final String replyTo = generateLongString() + "/" + generateLongString();
    Properties properties = new Properties();
    properties.setReplyTo(replyTo);
    Message_1_0 message = createTestMessage(properties);
    try {
        _messageConverter.convert(message, _namedAddressSpace);
        fail("expected exception not thrown");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Aggregations

MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)31 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)31 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)21 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)15 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)14 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)12 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)12 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)11 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)10 Matchers.anyString (org.mockito.Matchers.anyString)10 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)9 Exchange (org.apache.qpid.server.model.Exchange)8 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)7 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)5 Queue (org.apache.qpid.server.model.Queue)4 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)4 MessageDestination (org.apache.qpid.server.message.MessageDestination)3 HashMap (java.util.HashMap)2 DestinationAddress (org.apache.qpid.server.model.DestinationAddress)2 Header (org.apache.qpid.server.protocol.v0_10.transport.Header)2