Example usage for org.springframework.amqp.core MessageProperties getType

List of usage examples for org.springframework.amqp.core MessageProperties getType

Introduction

In this page you can find the example usage for org.springframework.amqp.core MessageProperties getType.

Prototype

public String getType() 

Source Link

Usage

From source file:org.springframework.amqp.rabbit.support.RabbitUtils.java

public static BasicProperties extractBasicProperties(Message message, String charset) {
    if (message == null || message.getMessageProperties() == null) {
        return null;
    }// w w w. j  av a 2s  .  c  om
    MessageProperties source = message.getMessageProperties();
    BasicProperties target = new BasicProperties();
    target.setHeaders(source.getHeaders());
    target.setTimestamp(source.getTimestamp());
    target.setMessageId(source.getMessageId());
    target.setUserId(source.getUserId());
    target.setAppId(source.getAppId());
    target.setClusterId(source.getClusterId());
    target.setType(source.getType());
    MessageDeliveryMode deliveryMode = source.getDeliveryMode();
    if (deliveryMode != null) {
        target.setDeliveryMode(MessageDeliveryMode.toInt(deliveryMode));
    }
    target.setExpiration(source.getExpiration());
    target.setPriority(source.getPriority());
    target.setContentType(source.getContentType());
    target.setContentEncoding(source.getContentEncoding());
    byte[] correlationId = source.getCorrelationId();
    if (correlationId != null && correlationId.length > 0) {
        try {
            target.setCorrelationId(new String(correlationId, charset));
        } catch (UnsupportedEncodingException ex) {
            throw new AmqpUnsupportedEncodingException(ex);
        }
    }
    Address replyTo = source.getReplyTo();
    if (replyTo != null) {
        target.setReplyTo(replyTo.toString());
    }
    return target;
}