本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
二进制数据处理更改
在版本 1 中,二进制数据是直接使用ByteBuffer
对象处理的。在版本 2 中,SDK 使用的SdkBytes
对象提供了一种更方便且类型安全的二进制数据处理方式。
您可以使用迁移工具ByteBuffer自动转换为SdkBytes
,也可以通过调用asByteBuffer()
返回的SdkBytes
对象来手动转换它们。
例 -从版本 1 中的消息属性中获取二进制数据
// Get binary data from a message attribute MessageAttributeValue messageAttributeValue = new MessageAttributeValue(); ByteBuffer binaryValue = messageAttributeValue.getBinaryValue(); String binaryString = new String(messageAttributeValue.getBinaryValue().array());
例 -从版本 2 中的消息属性中获取二进制数据
// Get binary data from a message attribute MessageAttributeValue messageAttributeValue = MessageAttributeValue.builder().build(); ByteBuffer binaryValue = messageAttributeValue.binaryValue().asByteBuffer(); String binaryString = new String(messageAttributeValue.binaryValue().asByteBuffer().array());