Search in sources :

Example 46 with MessageProperties

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

the class PropertyConverter_0_10_to_InternalTest 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 InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    assertEquals("Unexpected reply-to", exchangeName, convertedMessage.getMessageHeader().getReplyTo());
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 47 with MessageProperties

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

the class PropertyConverter_0_10_to_InternalTest method testCorrelationIdConversionWhenNotString.

public void testCorrelationIdConversionWhenNotString() {
    final byte[] correlationId = new byte[] { (byte) 0xc3, 0x28 };
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setCorrelationId(correlationId);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    assertEquals("Unexpected correlationId", new String(correlationId, UTF_8), convertedMessage.getMessageHeader().getCorrelationId());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 48 with MessageProperties

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

the class PropertyConverter_0_10_to_InternalTest method testJmsTypeConversion.

public void testJmsTypeConversion() {
    final String type = "test-type";
    final Map<String, Object> headers = Collections.singletonMap("x-jms-type", type);
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setApplicationHeaders(headers);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    assertEquals("Unexpected subject", type, convertedMessage.getMessageHeader().getType());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 49 with MessageProperties

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

the class PropertyConverter_0_10_to_InternalTest method testApplicationIdConversion.

public void testApplicationIdConversion() {
    String applicationId = "testAppId";
    MessageProperties messageProperties = new MessageProperties();
    messageProperties.setAppId(applicationId.getBytes(UTF_8));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    assertEquals("Unexpected app-id", applicationId, convertedMessage.getMessageHeader().getAppId());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 50 with MessageProperties

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

the class MessageConverter_Internal_to_v0_10 method convertMetaData.

private MessageMetaData_0_10 convertMetaData(final InternalMessage serverMsg, final NamedAddressSpace addressSpace, final String bodyMimeType, final int size) {
    DeliveryProperties deliveryProps = new DeliveryProperties();
    MessageProperties messageProps = new MessageProperties();
    deliveryProps.setDeliveryMode(serverMsg.isPersistent() ? MessageDeliveryMode.PERSISTENT : MessageDeliveryMode.NON_PERSISTENT);
    long expiration = serverMsg.getExpiration();
    if (expiration > 0) {
        deliveryProps.setExpiration(expiration);
        deliveryProps.setTtl(Math.max(0, expiration - serverMsg.getArrivalTime()));
    }
    InternalMessageHeader messageHeader = serverMsg.getMessageHeader();
    deliveryProps.setPriority(MessageDeliveryPriority.get(messageHeader.getPriority()));
    convertToAndInitialRoutingKey(serverMsg, deliveryProps, addressSpace);
    deliveryProps.setTimestamp(messageHeader.getTimestamp());
    messageProps.setContentEncoding(ensureStr8("content-encoding", messageHeader.getEncoding()));
    messageProps.setContentLength(size);
    messageProps.setContentType(bodyMimeType);
    if (messageHeader.getCorrelationId() != null) {
        messageProps.setCorrelationId(ensureVBin16("correlation-id", messageHeader.getCorrelationId().getBytes(UTF_8)));
    }
    validateValue(messageHeader.getHeaderMap(), "application-headers");
    messageProps.setApplicationHeaders(messageHeader.getHeaderMap());
    String messageIdAsString = messageHeader.getMessageId();
    if (messageIdAsString != null) {
        try {
            if (messageIdAsString.startsWith("ID:")) {
                messageIdAsString = messageIdAsString.substring(3);
            }
            messageProps.setMessageId(UUID.fromString(messageIdAsString));
        } catch (IllegalArgumentException iae) {
        // ignore message id is not a UUID
        }
    }
    String userId = messageHeader.getUserId();
    if (userId != null) {
        byte[] bytes = userId.getBytes(UTF_8);
        if (bytes.length <= MAX_VBIN16_LENGTH) {
            messageProps.setUserId(bytes);
        }
    }
    final String origReplyTo = messageHeader.getReplyTo();
    if (origReplyTo != null && !origReplyTo.equals("")) {
        messageProps.setReplyTo(getReplyTo(addressSpace, origReplyTo));
    }
    Header header = new Header(deliveryProps, messageProps, null);
    return new MessageMetaData_0_10(header, size, serverMsg.getArrivalTime());
}
Also used : Header(org.apache.qpid.server.protocol.v0_10.transport.Header) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Aggregations

MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)121 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)90 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)63 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)45 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)44 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)39 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)37 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)31 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)24 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)20 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)18 Matchers.anyString (org.mockito.Matchers.anyString)15 HashMap (java.util.HashMap)10 UUID (java.util.UUID)10 Header (org.apache.qpid.server.protocol.v0_10.transport.Header)10 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)9 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)7 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)6 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)5