Example usage for com.rabbitmq.client LongString length

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

Introduction

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

Prototype

public long length();

Source Link

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