问题
Working on SQS to queue some of my uploads coming from the client. I am getting below error:
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);
回答1:
According to the Limits Related to Messages documentation for Amazon SQS:
Message size
The minimum message size is 1 byte (1 character). The maximum is 262,144 bytes (256 KB).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.
The library basically stores the data in Amazon S3 and then inserts a reference into the Amazon SQS messages.
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.
来源:https://stackoverflow.com/questions/43738341/amazon-sqs-more-than-2gb-data