Search in sources :

Example 91 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_v1_0 method convertMetaData.

@Override
protected MessageMetaData_1_0 convertMetaData(final InternalMessage serverMessage, final EncodingRetainingSection<?> bodySection, final SectionEncoder sectionEncoder) {
    Header header = new Header();
    header.setDurable(serverMessage.isPersistent());
    header.setPriority(UnsignedByte.valueOf(serverMessage.getMessageHeader().getPriority()));
    if (serverMessage.getExpiration() != 0l && serverMessage.getArrivalTime() != 0l && serverMessage.getExpiration() >= serverMessage.getArrivalTime()) {
        header.setTtl(UnsignedInteger.valueOf(serverMessage.getExpiration() - serverMessage.getArrivalTime()));
    }
    Properties properties = new Properties();
    if (serverMessage.getMessageHeader().getEncoding() != null) {
        properties.setContentEncoding(Symbol.valueOf(serverMessage.getMessageHeader().getEncoding()));
    }
    properties.setCorrelationId(getCorrelationId(serverMessage));
    properties.setCreationTime(new Date(serverMessage.getMessageHeader().getTimestamp()));
    properties.setMessageId(getMessageId(serverMessage));
    Symbol contentType = getContentTypeSymbol(serverMessage.getMessageBody(), serverMessage.getMessageHeader().getMimeType());
    properties.setContentType(contentType);
    final String userId = serverMessage.getMessageHeader().getUserId();
    if (userId != null) {
        properties.setUserId(new Binary(userId.getBytes(StandardCharsets.UTF_8)));
    }
    properties.setReplyTo(serverMessage.getMessageHeader().getReplyTo());
    properties.setTo(serverMessage.getTo());
    ApplicationProperties applicationProperties = null;
    if (!serverMessage.getMessageHeader().getHeaderNames().isEmpty()) {
        try {
            applicationProperties = new ApplicationProperties(serverMessage.getMessageHeader().getHeaderMap());
        } catch (IllegalArgumentException e) {
            throw new MessageConversionException("Could not convert message from internal to 1.0" + " because conversion of 'application headers' failed.", e);
        }
    }
    final MessageAnnotations messageAnnotation = createMessageAnnotation(serverMessage.getMessageBody(), serverMessage.getMessageHeader().getMimeType(), bodySection);
    return new MessageMetaData_1_0(header.createEncodingRetainingSection(), null, messageAnnotation == null ? null : messageAnnotation.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties == null ? null : applicationProperties.createEncodingRetainingSection(), null, serverMessage.getArrivalTime(), bodySection.getEncodedSize());
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) Date(java.util.Date)

Example 92 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.

the class MessageConverter_from_1_0 method getContentType.

public static Symbol getContentType(final Message_1_0 serverMsg) {
    final PropertiesSection propertiesSection = serverMsg.getPropertiesSection();
    if (propertiesSection != null) {
        final Properties properties = propertiesSection.getValue();
        propertiesSection.dispose();
        if (properties != null) {
            return properties.getContentType();
        }
    }
    return null;
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 93 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.

the class MessageConverter_from_1_0 method getGroupId.

public static String getGroupId(final Message_1_0 serverMsg) {
    final PropertiesSection propertiesSection = serverMsg.getPropertiesSection();
    if (propertiesSection != null) {
        final Properties properties = propertiesSection.getValue();
        propertiesSection.dispose();
        if (properties != null) {
            return properties.getGroupId();
        }
    }
    return null;
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 94 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.

the class MessageConverter_from_1_0 method getAbsoluteExpiryTime.

public static Date getAbsoluteExpiryTime(final Message_1_0 serverMsg) {
    final PropertiesSection propertiesSection = serverMsg.getPropertiesSection();
    if (propertiesSection != null) {
        final Properties properties = propertiesSection.getValue();
        propertiesSection.dispose();
        if (properties != null) {
            return properties.getAbsoluteExpiryTime();
        }
    }
    return null;
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 95 with Properties

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.

the class MessageConverter_from_1_0 method getGroupSequence.

public static UnsignedInteger getGroupSequence(final Message_1_0 serverMsg) {
    final PropertiesSection propertiesSection = serverMsg.getPropertiesSection();
    if (propertiesSection != null) {
        final Properties properties = propertiesSection.getValue();
        propertiesSection.dispose();
        if (properties != null) {
            return properties.getGroupSequence();
        }
    }
    return null;
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Aggregations

Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)203 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)174 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)156 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)80 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)76 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)68 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)67 Matchers.anyString (org.mockito.Matchers.anyString)67 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)65 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)51 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)50 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)48 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)33 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)27 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)25 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)18 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)15 Date (java.util.Date)14 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)14 HashMap (java.util.HashMap)12