Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/sns/lib/sns/AbstractSnsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import type { SNS_MESSAGE_BODY_TYPE } from '../types/MessageTypes.ts'
import { deleteSns, initSns } from '../utils/snsInitter.ts'

// https://docs.aws.amazon.com/general/latest/gr/sns.html
export const SNS_MESSAGE_MAX_SIZE = 256 * 1024 // 256KB
export const SNS_MESSAGE_HARD_LIMIT = 256 * 1024 // 256KB - AWS SNS total message size limit (body + attributes)
export const SNS_MESSAGE_ATTRIBUTE_BUFFER = 30 * 1024 // 30KB - reserved space for message attributes and overhead
export const SNS_MESSAGE_MAX_SIZE = SNS_MESSAGE_HARD_LIMIT - SNS_MESSAGE_ATTRIBUTE_BUFFER // 226KB - maximum allowed message body size

export type SNSDependencies = QueueDependencies & {
snsClient: SNSClient
Expand Down
4 changes: 2 additions & 2 deletions packages/sns/lib/utils/snsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ export async function findSubscriptionByTopicAndQueue(
* Calculates the size of an outgoing SNS message.
*
* SNS imposes a 256 KB limit on the total size of a message, which includes both the message body and any metadata (attributes).
* This function currently computes the size based solely on the message body, as no attributes are included at this time.
* For future updates, if message attributes are added, their sizes should also be considered.
* This function computes the size based solely on the message body. The reserved buffer for message attributes and overhead
* is accounted for in SNS_MESSAGE_ATTRIBUTE_BUFFER, which is subtracted from SNS_MESSAGE_HARD_LIMIT to derive SNS_MESSAGE_MAX_SIZE.
*
* Reference: https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html
*
Expand Down
4 changes: 3 additions & 1 deletion packages/sqs/lib/sqs/AbstractSqsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import type { SQSMessage } from '../types/MessageTypes.ts'
import { deleteSqs, initSqs } from '../utils/sqsInitter.ts'

// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html
export const SQS_MESSAGE_MAX_SIZE = 1024 * 1024 // 1 MiB
export const SQS_MESSAGE_HARD_LIMIT = 1024 * 1024 // 1 MiB - AWS SQS total message size limit (body + attributes)
export const SQS_MESSAGE_ATTRIBUTE_BUFFER = 30 * 1024 // 30KB - reserved space for message attributes and overhead
export const SQS_MESSAGE_MAX_SIZE = SQS_MESSAGE_HARD_LIMIT - SQS_MESSAGE_ATTRIBUTE_BUFFER // 994KB - maximum allowed message body size
export const SQS_RESOURCE_ANY = Symbol('any')
export const SQS_RESOURCE_CURRENT_QUEUE = Symbol('current_queue')

Expand Down
4 changes: 2 additions & 2 deletions packages/sqs/lib/utils/sqsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ export async function deleteQueue(
* Calculates the size of an outgoing SQS message.
*
* SQS imposes a 1 MiB limit on the total size of a message, which includes both the message body and any metadata (attributes).
* This function currently computes the size based solely on the message body, as no attributes are included at this time.
* For future updates, if message attributes are added, their sizes should also be considered.
* This function computes the size based solely on the message body. The reserved buffer for message attributes and overhead
* is accounted for in SQS_MESSAGE_ATTRIBUTE_BUFFER, which is subtracted from SQS_MESSAGE_HARD_LIMIT to derive SQS_MESSAGE_MAX_SIZE.
*
* Reference: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-metadata.html#sqs-message-attributes
*/
Expand Down
Loading