Skip to content

send_message_batch() fails when each message is below DEFAULT_MESSAGE_SIZE_THRESHOLD but in total are greater than 262144 #25

Description

@bweisscyberark

Description

When attempting to send a batch of messages where each message is below the DEFAULT_MESSAGE_SIZE_THRESHOLD but the total size exceeds 262144 bytes, boto3 sqs client's send_message_batch() function fails with a BatchRequestTooLong error.

Steps to Reproduce

  1. Initialize the SQS client with large payload support:
import boto3
import sqs_extended_client
sqs_client: SQSClient = boto3.client('sqs')
sqs_client.large_payload_support = 'my_bucket_name'
queue_url = 'my_queue_url'
  1. Attempt to send a batch of messages, each below the size threshold, but whose total size is above the size threshold:
sqs_client.send_message_batch(QueueUrl=queue_url, Entries=[{'Id': '1','MessageBody':'A'*200000}, {'Id': '2','MessageBody':'B'*200000}])

Expected Behavior

The batch of messages should be sent successfully.

Actual Behavior

The operation fails with the following error:
{BatchRequestTooLong}BatchRequestTooLong('An error occurred (AWS.SimpleQueueService.BatchRequestTooLong) when calling the SendMessageBatch operation: Batch requests cannot be longer than 262144 bytes. You have sent 400000 bytes.')

Additional Information

Just to verify all is configured properly on my setup, sending the large messages does work as intended, via the s3 bucket:

sqs_client.send_message_batch(QueueUrl=queue_url, Entries=[{'Id': '1','MessageBody':'A'*400000}])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions