File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ import type { SNS_MESSAGE_BODY_TYPE } from '../types/MessageTypes.ts'
1010import { deleteSns , initSns } from '../utils/snsInitter.ts'
1111
1212// https://docs.aws.amazon.com/general/latest/gr/sns.html
13- export const SNS_MESSAGE_MAX_SIZE = 256 * 1024 // 256KB
13+ export const SNS_MESSAGE_HARD_LIMIT = 256 * 1024 // 256KB - AWS SNS total message size limit (body + attributes)
14+ export const SNS_MESSAGE_ATTRIBUTE_BUFFER = 30 * 1024 // 30KB - reserved space for message attributes and overhead
15+ export const SNS_MESSAGE_MAX_SIZE = SNS_MESSAGE_HARD_LIMIT - SNS_MESSAGE_ATTRIBUTE_BUFFER // 226KB - maximum allowed message body size
1416
1517export type SNSDependencies = QueueDependencies & {
1618 snsClient : SNSClient
Original file line number Diff line number Diff line change @@ -187,8 +187,8 @@ export async function findSubscriptionByTopicAndQueue(
187187 * Calculates the size of an outgoing SNS message.
188188 *
189189 * SNS imposes a 256 KB limit on the total size of a message, which includes both the message body and any metadata (attributes).
190- * This function currently computes the size based solely on the message body, as no attributes are included at this time.
191- * For future updates, if message attributes are added, their sizes should also be considered .
190+ * This function computes the size based solely on the message body. The reserved buffer for message attributes and overhead
191+ * is accounted for in SNS_MESSAGE_ATTRIBUTE_BUFFER, which is subtracted from SNS_MESSAGE_HARD_LIMIT to derive SNS_MESSAGE_MAX_SIZE .
192192 *
193193 * Reference: https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html
194194 *
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ import type { SQSMessage } from '../types/MessageTypes.ts'
99import { deleteSqs , initSqs } from '../utils/sqsInitter.ts'
1010
1111// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html
12- export const SQS_MESSAGE_MAX_SIZE = 1024 * 1024 // 1 MiB
12+ export const SQS_MESSAGE_HARD_LIMIT = 1024 * 1024 // 1 MiB - AWS SQS total message size limit (body + attributes)
13+ export const SQS_MESSAGE_ATTRIBUTE_BUFFER = 30 * 1024 // 30KB - reserved space for message attributes and overhead
14+ export const SQS_MESSAGE_MAX_SIZE = SQS_MESSAGE_HARD_LIMIT - SQS_MESSAGE_ATTRIBUTE_BUFFER // 994KB - maximum allowed message body size
1315export const SQS_RESOURCE_ANY = Symbol ( 'any' )
1416export const SQS_RESOURCE_CURRENT_QUEUE = Symbol ( 'current_queue' )
1517
Original file line number Diff line number Diff line change @@ -275,8 +275,8 @@ export async function deleteQueue(
275275 * Calculates the size of an outgoing SQS message.
276276 *
277277 * SQS imposes a 1 MiB limit on the total size of a message, which includes both the message body and any metadata (attributes).
278- * This function currently computes the size based solely on the message body, as no attributes are included at this time.
279- * For future updates, if message attributes are added, their sizes should also be considered .
278+ * This function computes the size based solely on the message body. The reserved buffer for message attributes and overhead
279+ * is accounted for in SQS_MESSAGE_ATTRIBUTE_BUFFER, which is subtracted from SQS_MESSAGE_HARD_LIMIT to derive SQS_MESSAGE_MAX_SIZE .
280280 *
281281 * Reference: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-metadata.html#sqs-message-attributes
282282 */
You can’t perform that action at this time.
0 commit comments