Skip to content

2.0: Enforce MessageRetentionPeriod and per-queue MaximumMessageSize - #1277

Merged
micossow merged 2 commits into
masterfrom
sqs-retention-and-max-message-size-2.0
Nov 7, 2026
Merged

micossow merged 2 commits into
masterfrom
sqs-retention-and-max-message-size-2.0

Conversation

@micossow

@micossow micossow commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Implements the "SQS behaviour" items from docs/BACKLOG.md.

What changes

MessageRetentionPeriod and MaximumMessageSize used to be accepted and ignored. They are now stored, returned by GetQueueAttributes and enforced. When a queue doesn't set them, the default depends on sqs-limits:

sqs-limits Queue doesn't set it Queue sets it
strict (default) SQS defaults: 4-day retention, 1 MiB max size enforced; must be in the SQS range (60 s–14 days, 1024–1048576 bytes)
relaxed no expiry, no size limit (as in 1.x) enforced; any positive value
  • Retention:
    • Expired messages are skipped by ReceiveMessage and left out of the queue statistics.
    • A check every second removes them and sends MessageRemoved events, so messages-storage deletes them too. A lower bound on the oldest creation time means it only scans the queue when a message could have expired.
    • Messages moved to a DLQ keep their original send time.
    • Lowering a queue's retention applies to the messages already on it.
  • Size:
    • Counts the body plus each attribute's name, data type and value, in UTF-8 bytes, as SQS does. 1.x counted body characters only.
    • An oversized message fails with InvalidParameterValue ("Message must be shorter than N bytes").
    • A batch over 1 MiB in total fails with BatchRequestTooLong.
  • Config:
    • New keys message-retention-period and maximum-message-size for queue definitions and auto-create-queues.template.
    • Both are written to queues-storage and to the SQL queue data only when set. Data written by 1.x still loads (covered by tests).
  • Limits API:
    • New members maximumMessageSizeLimit, defaultMessageRetentionPeriod and messageRetentionPeriodLimit.
    • maxMessageLength is renamed to maxMessageSize.
    • verifyMessageLength is replaced by verifyMessageSize.

Upgrade note: with the default strict limits, persisted messages older than 4 days are deleted on the first start of 2.0. The release notes explain this and how to opt out.

Docs: the README has a new "SQS limits" section and the new keys in its examples. The 2.0 release notes and the backlog are updated.

Testing

  • sbt testFull on Scala 3: all suites pass, including the SDK v1 and v2 integration suites.
  • Scala 2.13: everything compiles; the core and persistence tests pass.
  • New tests:
    • MessageRetentionTest: strict and relaxed defaults, per-queue retention, statistics, lowering retention, listener events.
    • LimitsTest: size, retention and maximum-size checks.
    • DBQueueTest: 1.x blob compatibility and round trip.
    • Config read/write for the new keys.
    • SDK tests for the attribute defaults, setting the attributes, range errors, and per-queue size enforcement.
  • scalafmtCheckAll passes.

🤖 Generated with Claude Code

micossow and others added 2 commits November 7, 2026 17:29
- Store, return and enforce MessageRetentionPeriod and MaximumMessageSize
  (previously accepted and ignored). Defaults follow sqs-limits: strict
  uses the SQS defaults (4 days, 1 MiB), relaxed keeps the 1.x behaviour
  (no expiry, no size limit). An explicit value is always enforced;
  strict validates it against the SQS ranges.
- Expired messages are skipped on receive and in statistics, and removed
  by a 1 s timer, emitting MessageRemoved events so persistence deletes
  them. A lower bound on message creation time keeps the check cheap.
- Message size counts the body and attributes in UTF-8 bytes, as SQS does.
  Oversized messages fail with InvalidParameterValue; oversized batches
  with BatchRequestTooLong.
- New queue config keys message-retention-period and maximum-message-size,
  written to queues-storage and the SQL queue data; 1.x data still loads.
- Limits: new members for retention and maximum size, maxMessageLength
  renamed to maxMessageSize.
- Update README, backlog and the 2.0 release notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e image reflection metadata

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@micossow
micossow merged commit bb1d74f into master Nov 7, 2026
34 of 40 checks passed
@micossow
micossow deleted the sqs-retention-and-max-message-size-2.0 branch November 7, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant