Skip to content

feat(utils/sqs): add MessageDeduplicationId support for FIFO sends#1566

Merged
akshaymagapu merged 1 commit intomainfrom
feat/sqs-message-dedup-id
Apr 29, 2026
Merged

feat(utils/sqs): add MessageDeduplicationId support for FIFO sends#1566
akshaymagapu merged 1 commit intomainfrom
feat/sqs-message-dedup-id

Conversation

@akshaymagapu
Copy link
Copy Markdown
Contributor

Summary

  • Add an optional fourth parameter messageDeduplicationId to SQS.sendMessage.
  • For FIFO queues, applies it as MessageDeduplicationId on the SendMessageCommand only when the caller passes a non-empty value.
  • Ignored on standard queues and on FIFO queues where the caller relies on content-based dedup.

Why

FIFO queues with content_based_deduplication = false require producers to supply an explicit MessageDeduplicationId on every publish — without one, SQS rejects the call. Today the helper has no way to pass it through, so callers either bypass the helper or rely on content-based dedup at the queue level.

This change unblocks producers (spacecat-audit-worker, mysticat-projector-service) that need to publish to the analytics ingestion FIFO queue introduced in spacecat-infrastructure#480, where the topic and queue both have explicit dedup disabled per the design (producer sets explicit MessageDeduplicationId).

Backward compatible — existing 2/3-arg call sites are unchanged.

Test plan

  • New unit tests cover: dedup-id applied on FIFO; dedup-id stripped on standard; group-id without dedup-id still works (back-compat).
  • npx mocha --spec test/sqs.test.js --exit — all 1035 utils tests pass.
  • Lint clean.

Coordination

Pairs with consumer PRs that use the new parameter on the analytics FIFO publish path. This PR can land independently — it is purely additive.

🤖 Generated with Claude Code

FIFO queues with content-based deduplication disabled require producers
to supply an explicit MessageDeduplicationId on every publish. The
existing sendMessage helper accepted MessageGroupId but had no way to
pass MessageDeduplicationId through, so callers either had to bypass
the helper or rely on content-based dedup at the queue level.

This adds an optional fourth parameter, mirroring the existing
messageGroupId pattern: ignored on standard queues, applied only on
FIFO queues, and only when the caller passes a non-empty value.

Backward compatible — existing 2/3-arg call sites are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@akshaymagapu akshaymagapu merged commit b3b9511 into main Apr 29, 2026
5 checks passed
@akshaymagapu akshaymagapu deleted the feat/sqs-message-dedup-id branch April 29, 2026 09:14
solaris007 pushed a commit that referenced this pull request Apr 29, 2026
## [@adobe/spacecat-shared-utils-v1.113.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.112.5...@adobe/spacecat-shared-utils-v1.113.0) (2026-04-29)

### Features

* **utils/sqs:** add MessageDeduplicationId support for FIFO sends ([#1566](#1566)) ([b3b9511](b3b9511))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version @adobe/spacecat-shared-utils-v1.113.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

akshaymagapu added a commit to adobe/spacecat-audit-worker that referenced this pull request Apr 29, 2026
#2438)

## Summary

Pairs with
[spacecat-infrastructure#480](adobe/spacecat-infrastructure#480),
which converts the analytics ingestion path (SNS topic + SQS queue +
DLQ) to FIFO. Once that infra PR applies, the audit-worker's
`dispatchAnalyticsEvent` will hard-fail on every attempt because the
FIFO queue rejects publishes that lack `MessageGroupId` and
`MessageDeduplicationId` (the new queue has `content_based_deduplication
= false`).

This PR adds the missing attributes.

## Changes

**`src/support/sqs.js`** — extend the local `SQS.sendMessage` signature
with an optional `msgDedupId` parameter and forward it as
`MessageDeduplicationId`. Backward compatible: only set when the caller
supplies a non-empty value, so all existing 2/3-arg call sites are
untouched.

**`src/cdn-logs-report/agentic-daily-export.js`** —
`dispatchAnalyticsEvent`:
- `MessageGroupId = ` `` `${pipeline_id}:${site_id}` `` per the infra
PR's convention. Concurrent imports for the same scope serialize through
the FIFO group; different sites/pipelines run in parallel.
- `MessageDeduplicationId = batchId` (uuid generated per export run).
Retries inside SQS's 5-minute dedup window collapse to a single
delivery.
- Return shape now exposes `messageGroupId` and `messageDeduplicationId`
for observability.

## Why this group key

`(pipeline_id, site_id)` matches the infra PR convention so the
audit-worker's `agentic_traffic` import group is independent of the
projector's post-success `agentic_traffic_daily_refresh` and
`agentic_traffic_weekly_refresh` groups (different DB tables, no
contention). Putting them in the same group would needlessly serialize
unrelated work.

## Test plan

- [x] `npx mocha --spec test/support/sqs.test.js --spec
test/audits/cdn-logs-report/agentic-daily-export.test.js --exit` — 28
passing.
- [x] New tests cover: dedup-id applied on FIFO publish, dedup-id
omitted when not provided, log line includes DedupID, end-to-end
`dispatchAnalyticsEvent` returns the new fields and calls `sendMessage`
with all five args.
- [x] Lint clean.
- [ ] Coordinate apply-time with infra PR #480.

## Related

- Pairs with
[spacecat-infrastructure#480](adobe/spacecat-infrastructure#480)
— must land + deploy in lockstep.
- Pairs with the projector PR (separate) which adds FIFO attributes on
the post-success refresh enqueues + DLQ writes.
- Optional follow-up:
[spacecat-shared#1566](adobe/spacecat-shared#1566)
adds the same `messageDeduplicationId` parameter to the shared utils
helper, useful for any future FIFO consumer using the shared sender.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants