List of usage examples for com.amazonaws.services.sqs.model MessageAttributeValue getDataType
public String getDataType()
Amazon SQS supports the following logical data types: String
, Number
, and Binary
.
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 www .j a v a2 s. c o m String stringVal = entryVal.getStringValue(); if (stringVal != null) { totalMsgAttributesSize += getStringSizeInBytes(entryVal.getStringValue()); } ByteBuffer binaryVal = entryVal.getBinaryValue(); if (binaryVal != null) { totalMsgAttributesSize += binaryVal.array().length; } } return totalMsgAttributesSize; }
From source file:org.springframework.cloud.aws.messaging.core.QueueMessageUtils.java
License:Apache License
private static Object getNumberValue(MessageAttributeValue value) { String numberType = value.getDataType().substring(MessageAttributeDataTypes.NUMBER.length() + 1); try {/*from ww w . j av a 2 s. co m*/ Class<? extends Number> numberTypeClass = Class.forName(numberType).asSubclass(Number.class); return NumberUtils.parseNumber(value.getStringValue(), numberTypeClass); } catch (ClassNotFoundException e) { throw new MessagingException(String.format( "Message attribute with value '%s' and data type '%s' could not be converted " + "into a Number because target class was not found.", value.getStringValue(), value.getDataType()), e); } }