Skip to content

Carry the correlation id of the unit of work in an optional column. - #12

Closed
gustavofreze wants to merge 1 commit into
mainfrom
feature/correlation-id-column
Closed

gustavofreze wants to merge 1 commit into
mainfrom
feature/correlation-id-column

Conversation

@gustavofreze

Copy link
Copy Markdown
Member

Please follow the contributing guidelines.

Summary

The outbox can now record, next to each event, the correlation id of the unit of work that emitted it. A consumer
that receives the event can then log it under the same id as the request that caused it, instead of starting a new
trace at every hop.

  • Columns::builder()->withCorrelationId(name:) enables an optional column. No column is written by default, so
    existing tables and layouts keep producing exactly the same statement and the same eight bindings.
  • DoctrineOutboxRepository takes an optional correlationId reader, a Closure(): string called at each write. One
    repository serves every request of a long-lived container, because the value is read when the row is written, not
    when the repository is built.
  • An empty string is stored as NULL, which is what a worker outside any request writes. A reader without the column,
    or the column without a reader, writes nothing or NULL, and never fails.
  • The statement is now built from the column list, so the optional column goes last, after occurred_at.
  • The README documents the column, the new parameter and the builder method.

Related issue

None.

Checklist

  • Tests added or updated.
  • Documentation updated when applicable.
  • composer review passes.
  • composer tests passes.

@gustavofreze
gustavofreze deleted the feature/correlation-id-column branch September 27, 2026 18:44
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