From 056ff0232d4ec91cd641d413981a1850db2d015b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?France=CC=81=20Wilke?= <francewilke@gmail.com> Date: Fri, 11 Feb 2022 13:09:23 +0200 Subject: [PATCH] Limit SQS messages to 200 KB --- sqs/sqs.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sqs/sqs.go b/sqs/sqs.go index cc71f3e..e9fa2f6 100644 --- a/sqs/sqs.go +++ b/sqs/sqs.go @@ -126,10 +126,12 @@ func SendSQSMessage(msgr Messenger, objectToSend interface{}, currentRequestID * // If bigger than 200 KB upload message to s3 and send s3 file name to sqs // The sqs receiver should check the header to see if the message is in the body or on s3 - if len(jsonBytes) > 0 { + if len(jsonBytes) > 200000 { + headers[SQSMessageOnS3Key] = "true" id := uuid.New() filename := fmt.Sprintf("%v-%v", sqsType, id.String()) + logs.Info("SQS message too big, saving to S3 with filename = %s", filename) err := uploadMessageToS3(msgr.S3Session, msgr.S3BucketName, filename, jsonBytes) if err != nil { -- GitLab