Search in sources :

Example 11 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class DefinedGroupMessageGroupManager method getKey.

private Object getKey(QueueEntry entry) {
    ServerMessage message = entry.getMessage();
    AMQMessageHeader messageHeader = message == null ? null : message.getMessageHeader();
    Object groupVal = messageHeader == null ? _defaultGroup : _groupId == null ? messageHeader.getGroupId() : messageHeader.getHeader(_groupId);
    if (groupVal == null) {
        groupVal = _defaultGroup;
    }
    return groupVal;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 12 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testLongContentEncodingConversion.

public void testLongContentEncodingConversion() throws IOException {
    String contentEncoding = generateLongString();
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getEncoding()).thenReturn(contentEncoding);
    InternalMessage originalMessage = createTestMessage(header);
    try {
        _messageConverter.convert(originalMessage, _addressSpace);
        fail("Expected exception is not thrown");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 13 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testReplyToConversionWhenExchangeAndRoutingKeyAreSpecified.

public void testReplyToConversionWhenExchangeAndRoutingKeyAreSpecified() throws IOException {
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    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(_addressSpace.getAttainedMessageDestination(exchangeName)).thenReturn(exchange);
    when(header.getReplyTo()).thenReturn(replyTo);
    InternalMessage originalMessage = createTestMessage(header);
    MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    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) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString)

Example 14 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testReplyToConversionWhenExchangeIsSpecified.

public void testReplyToConversionWhenExchangeIsSpecified() throws IOException {
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    final String replyTo = "myTestExchange";
    final Exchange exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(replyTo);
    when(_addressSpace.getAttainedMessageDestination(replyTo)).thenReturn(exchange);
    when(header.getReplyTo()).thenReturn(replyTo);
    InternalMessage originalMessage = createTestMessage(header);
    MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    final ReplyTo convertedReplyTo = convertedMessage.getHeader().getMessageProperties().getReplyTo();
    assertEquals("Unexpected exchange", replyTo, convertedReplyTo.getExchange());
    assertEquals("Unexpected routing key", "", convertedReplyTo.getRoutingKey());
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString)

Example 15 with AMQMessageHeader

use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v0_10Test method testHeadersConversionWithUnsupportedTypes.

public void testHeadersConversionWithUnsupportedTypes() throws IOException {
    final Map<String, Object> properties = Collections.singletonMap("bigDecimalProperty", new BigDecimal(1));
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getHeaderNames()).thenReturn(properties.keySet());
    doAnswer(invocation -> {
        final String originalArgument = (String) (invocation.getArguments())[0];
        return properties.get(originalArgument);
    }).when(header).getHeader(any(String.class));
    InternalMessage originalMessage = createTestMessage(header);
    try {
        _messageConverter.convert(originalMessage, _addressSpace);
        fail("Expected exception not thrown");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) BigDecimal(java.math.BigDecimal)

Aggregations

AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)81 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)55 Matchers.anyString (org.mockito.Matchers.anyString)28 ServerMessage (org.apache.qpid.server.message.ServerMessage)16 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)15 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)11 HashMap (java.util.HashMap)10 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)8 MessageReference (org.apache.qpid.server.message.MessageReference)5 Queue (org.apache.qpid.server.model.Queue)5 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)5 Exchange (org.apache.qpid.server.model.Exchange)4 UUID (java.util.UUID)3 UnsignedLong (org.apache.qpid.server.protocol.v1_0.type.UnsignedLong)3 Date (java.util.Date)2 Set (java.util.Set)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)2 StoredMessage (org.apache.qpid.server.store.StoredMessage)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2