Example usage for com.amazonaws.services.sqs.model MessageAttributeValue getBinaryValue

List of usage examples for com.amazonaws.services.sqs.model MessageAttributeValue getBinaryValue

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs.model MessageAttributeValue getBinaryValue.

Prototype


public java.nio.ByteBuffer getBinaryValue() 

Source Link

Document

Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

Usage

From source file:com.amazon.sqs.javamessaging.AmazonSQSExtendedClient.java

License:Open Source License

private int getMsgAttributesSize(Map<String, MessageAttributeValue> msgAttributes) {
    int totalMsgAttributesSize = 0;
    for (Entry<String, MessageAttributeValue> entry : msgAttributes.entrySet()) {
        totalMsgAttributesSize += getStringSizeInBytes(entry.getKey());

        MessageAttributeValue entryVal = entry.getValue();
        if (entryVal.getDataType() != null) {
            totalMsgAttributesSize += getStringSizeInBytes(entryVal.getDataType());
        }//from ww  w. j a  va  2s.  com

        String stringVal = entryVal.getStringValue();
        if (stringVal != null) {
            totalMsgAttributesSize += getStringSizeInBytes(entryVal.getStringValue());
        }

        ByteBuffer binaryVal = entryVal.getBinaryValue();
        if (binaryVal != null) {
            totalMsgAttributesSize += binaryVal.array().length;
        }
    }
    return totalMsgAttributesSize;
}