Registry Mirror
Skip to content

Conversation

@adenhertog

@adenhertog adenhertog commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #322

Summary

Core stamps a messageId and sentAt on every outgoing message, every transport carries them through retries and the DLQ, and Transport gets a required endpointName.

Background

#258, #261, #262 and #264 all need a stable message id, a send time and the endpoint's name. This adds them once so those PRs don't each add them.

Problem

TransportMessage.id is the transport's native id: SQS changes it on fail, RabbitMQ made a new UUID per publish, and in-memory has none. Nothing recorded when a message was sent, and core had no way to know which endpoint it runs as.

Approach

  • MessageAttributes (bus-messages): optional messageId and sentAt (ISO 8601), also accepted by messageAttributes().
  • bus-core: prepareTransportOptions sets messageId: randomUUID() and sentAt: new Date().toISOString() unless the caller passes them. Neither is copied from the message being handled. Transport.endpointName is a required readonly property. InMemoryQueue takes an optional endpointName (default in-memory). It already passes the attributes object through toTransportMessage, so nothing changed there.
  • bus-sqs: messageId and sentAt are top-level SNS attributes in toMessageAttributeMap/fromMessageAttributeMap, so bus-sqs-lambda gets them for free (spec added). endpointName is queueName, or the name from queueArn.
  • bus-rabbitmq: the AMQP messageId property comes from the attribute. It falls back to randomUUID() only when the transport is called directly without one. sentAt goes in a sentAt header. endpointName is queueName.
  • bus-test: transportTests checks that a caller's messageId arrives unchanged, that a bus-stamped messageId/sentAt arrives, and that both stay the same on every retry and in the DLQ, for poisoned and failed messages. bus-test's in-memory.integration.ts now runs the full transportTests (it used to run only the round trip cases) through a small TransportTestInMemoryQueue fixture, so the in-memory queue is covered too.
  • Non-inheritance: a new bus-core integration test checks that a message sent from a handler gets a new messageId/sentAt but keeps the correlationId.
  • Docs: a new /guide/message-attributes/message-id page (snippet in docs/snippets/message-id.ts), linked from /guide/message-attributes and the sidebar. /transports/custom documents endpointName and the carry-through rule, the custom transport skeleton has both, and the bus-test README is re-synced. MIGRATING entries and a minor changeset are included, with Breaking: notes for Transport.endpointName and the stricter transportTests.

Checklist:

  • Every outgoing message has a unique messageId and sentAt that a handler's sends don't inherit: confirmed & fixed. The new transportTests and handler-context tests fail on master (8 failures with the stamping removed) and pass now.
  • A caller's messageId reaches the handler unchanged: confirmed & fixed (transportTests, every transport).
  • Both survive retry and dead-lettering on in-memory, SQS (+ lambda) and RabbitMQ: confirmed & fixed (transportTests against LocalStack and RabbitMQ, the in-memory suite, and the sqs-lambda spec).
  • Transport.endpointName on every transport, documented in /transports/custom: done.
  • Docs, MIGRATING and changeset: done.

Worth a close look:

🤖 Generated with Claude Code

adenhertog and others added 2 commits October 3, 2026 11:26
…endpointName

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…oint names

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@adenhertog
adenhertog force-pushed the issue-322-message-id-sent-at-endpoint branch from 6457046 to 150f4ba Compare October 3, 2026 01:27
@adenhertog
adenhertog merged commit 7e23496 into master Oct 3, 2026
5 checks passed
@adenhertog
adenhertog deleted the issue-322-message-id-sent-at-endpoint branch October 3, 2026 01:34
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.

Core message id, sent time and endpoint name

1 participant