Example usage for org.springframework.amqp.core MessageDeliveryMode toInt

List of usage examples for org.springframework.amqp.core MessageDeliveryMode toInt

Introduction

In this page you can find the example usage for org.springframework.amqp.core MessageDeliveryMode toInt.

Prototype

public static int toInt(MessageDeliveryMode mode) 

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;
    }/*ww  w  .ja  v a  2  s  .  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;
}