LrSqsMessageAttributeValue.binaryValueCopy
Returns a copy of the attribute's value as a binary.
public byte[] binaryValueCopy()
Return values
This function returns a binary array that represents a copy of attribute's value. If the data type of the value is not Binary, an exception is thrown.
Example
public int action() throws Throwable {
LrSqsClient.initClient(region, standardQueueUrl);
LrSqsMessageAttributeValue intValue = LrSqsClient.createMessageAttributeValueInt(24);
lr.output_message("type: " + intValue.dataType());
if (intValue.dataType()=="Number"){
int num = intValue.intValue();
String s = intValue.stringValue();
double d = intValue.doubleValue();
}
LrSqsMessageAttributeValue stringVal = LrSqsClient.createMessageAttributeValueString("2.4");
lr.output_message("type: " + stringVal.dataType());
double d = stringVal.doubleValue(); // the value can be converted to double
LrSqsMessageAttributeValue stringVal2 = LrSqsClient.createMessageAttributeValueString("myAttribute");
lr.output_message("type: " + stringVal2.dataType());
//double d = stringVal2.doubleValue(); // this line will throw exception - value cannot be converted to double.
//byte[] b = stringVal2.binaryValue(); // if the attribute is not binary, an exception will be thrown.
LrSqsMessageAttributeValue binaryVal = LrSqsClient.createMessageAttributeValueBinary("binaryAttrib");
lr.output_message("type: " + binaryVal.dataType());
byte[] b = binaryVal.binaryValue();
byte[] b_copy = binaryVal.binaryValueCopy();
LrSqsClient.closeClient();
return 0;
}