Example usage for com.rabbitmq.client LongString getStream

List of usage examples for com.rabbitmq.client LongString getStream

Introduction

In this page you can find the example usage for com.rabbitmq.client LongString getStream.

Prototype

public DataInputStream getStream() throws IOException;

Source Link

Document

Get the content stream.

Usage

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

License:Apache License

/**
 * Converts a LongString value to either a String or DataInputStream based on a length-driven threshold. If the
 * length is 1024 bytes or less, a String will be returned, otherwise a DataInputStream is returned.
 *///from  w  w  w. j a v  a  2s  . com
private Object convertLongString(LongString longString, String charset) {
    try {
        if (longString.length() <= 1024) {
            return new String(longString.getBytes(), charset);
        } else {
            return longString.getStream();
        }
    } catch (Exception e) {
        throw RabbitExceptionTranslator.convertRabbitAccessException(e);
    }
}