Example usage for org.springframework.amqp AmqpUnsupportedEncodingException AmqpUnsupportedEncodingException

List of usage examples for org.springframework.amqp AmqpUnsupportedEncodingException AmqpUnsupportedEncodingException

Introduction

In this page you can find the example usage for org.springframework.amqp AmqpUnsupportedEncodingException AmqpUnsupportedEncodingException.

Prototype

public AmqpUnsupportedEncodingException(Throwable cause) 

Source Link

Usage

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

public static RuntimeException convertRabbitAccessException(Throwable ex) {
    Assert.notNull(ex, "Exception must not be null");
    if (ex instanceof AmqpException) {
        return (AmqpException) ex;
    }/*from  www  . j av  a 2s  . com*/
    if (ex instanceof ShutdownSignalException) {
        return new AmqpConnectException((ShutdownSignalException) ex);
    }
    if (ex instanceof ConnectException) {
        return new AmqpConnectException((ConnectException) ex);
    }
    if (ex instanceof IOException) {
        return new AmqpIOException((IOException) ex);
    }
    if (ex instanceof UnsupportedEncodingException) {
        return new AmqpUnsupportedEncodingException(ex);
    }
    // fallback
    return new UncategorizedAmqpException(ex);
}

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

public static AmqpException convertRabbitAccessException(Throwable ex) {
    Assert.notNull(ex, "Exception must not be null");
    if (ex instanceof AmqpException) {
        return (AmqpException) ex;
    }//w  ww  . j a v  a2s .c om
    if (ex instanceof ConnectException) {
        return new AmqpConnectException((ConnectException) ex);
    }
    if (ex instanceof IOException) {
        return new AmqpIOException((IOException) ex);
    }
    if (ex instanceof UnsupportedEncodingException) {
        return new AmqpUnsupportedEncodingException(ex);
    }
    // fallback
    return new UncategorizedAmqpException(ex);
}

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

public static MessageProperties createMessageProperties(final BasicProperties source, final Envelope envelope,
        final String charset) {
    MessageProperties target = new MessageProperties();
    Map<String, Object> headers = source.getHeaders();
    if (!CollectionUtils.isEmpty(headers)) {
        for (Map.Entry<String, Object> entry : headers.entrySet()) {
            target.setHeader(entry.getKey(), entry.getValue());
        }//w  w w.ja v  a  2s.co  m
    }
    target.setTimestamp(source.getTimestamp());
    target.setMessageId(source.getMessageId());
    target.setUserId(source.getUserId());
    target.setAppId(source.getAppId());
    target.setClusterId(source.getClusterId());
    target.setType(source.getType());
    Integer deliverMode = source.getDeliveryMode();
    if (deliverMode != null) {
        target.setDeliveryMode(MessageDeliveryMode.fromInt(deliverMode));
    }
    target.setExpiration(source.getExpiration());
    target.setPriority(source.getPriority());
    target.setContentType(source.getContentType());
    target.setContentEncoding(source.getContentEncoding());
    String correlationId = source.getCorrelationId();
    if (correlationId != null) {
        try {
            target.setCorrelationId(source.getCorrelationId().getBytes(charset));
        } catch (UnsupportedEncodingException ex) {
            throw new AmqpUnsupportedEncodingException(ex);
        }
    }
    String replyTo = source.getReplyTo();
    if (replyTo != null) {
        target.setReplyTo(new Address(replyTo));
    }
    if (envelope != null) {
        target.setReceivedExchange(envelope.getExchange());
        target.setReceivedRoutingKey(envelope.getRoutingKey());
        target.setRedelivered(envelope.isRedeliver());
        target.setDeliveryTag(envelope.getDeliveryTag());
    }
    // TODO: what about messageCount?
    return target;
}

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 ww .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;
}