Amazon SQS超过2GB数据 [英] Amazon SQS more than 2GB data

查看:85
本文介绍了Amazon SQS超过2GB数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用SQS将来自客户端的一些上载内容排队.我遇到以下错误:

Working on SQS to queue some of my uploads coming from the client. I am getting below error:

com.amazonaws.services.sqs.model.AmazonSQSException:一个或多个参数无效.原因:消息必须短于262144字节. (服务:AmazonSQS;状态代码:400;错误代码:InvalidParameterValue;请求ID:

com.amazonaws.services.sqs.model.AmazonSQSException: One or more parameters are invalid. Reason: Message must be shorter than 262144 bytes. (Service: AmazonSQS; Status Code: 400; Error Code: InvalidParameterValue; Request ID:

我正在使用扩展的客户端库.这是我用来发送消息的代码:

I am using extended client library. Here are the code that I use to send message:

MessageAttributeValue msgAttr = new MessageAttributeValue();
byte [] byteArr=attachment.getBytes();
ByteBuffer buf = ByteBuffer.wrap(byteArr);
msgAttr.setBinaryValue(buf);
msgAttr.setDataType("Binary");
smr.addMessageAttributesEntry("attachment", msgAttr);

推荐答案

根据与Amazon SQS的消息相关的限制文档:

邮件大小
最小消息大小为1个字节(1个字符).最大为262,144字节(256 KB).

Message size
The minimum message size is 1 byte (1 character). The maximum is 262,144 bytes (256 KB).

要发送大于256 KB的消息,可以使用 Amazon适用于Java的SQS扩展客户端库.该库使您可以发送包含对Amazon S3中消息有效负载的引用的Amazon SQS消息. 最大有效负载大小为2 GB.

To send messages larger than 256 KB, you can use the Amazon SQS Extended Client Library for Java. This library allows you to send an Amazon SQS message that contains a reference to a message payload in Amazon S3. The maximum payload size is 2 GB.

该库基本上将数据存储在Amazon S3中,然后将引用插入到Amazon SQS消息中.

The library basically stores the data in Amazon S3 and then inserts a reference into the Amazon SQS messages.

无论出于何种原因,该库都会对附件实施2GB的限制.您可以尝试修改代码以处理更大的文件,也可以编写自己的代码,将对象存储在Amazon S3中并仅包含对亚马逊的引用Amazon SQS消息中的S3对象.

For whatever reason, the library enforces a 2GB limit on attachments. You could try and modify the code to handle a larger size file, or you could write your own code that stores the object in Amazon S3 and simply includes a reference to the amazon S3 object within the Amazon SQS messages.

这篇关于Amazon SQS超过2GB数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆