Skip to content

Comments

Ensure outbox stores message with same headers as regular repository#38

Open
axlon wants to merge 1 commit intoEventSaucePHP:mainfrom
axlon:outbox-event-id
Open

Ensure outbox stores message with same headers as regular repository#38
axlon wants to merge 1 commit intoEventSaucePHP:mainfrom
axlon:outbox-event-id

Conversation

@axlon
Copy link
Contributor

@axlon axlon commented Feb 10, 2026

Alternative to EventSaucePHP/EventSauce#247

Currently when a message is persisted, the event ID is not set until the very last moment (when the message is inserted into the database). This causes outbox repositories and message dispatchers to receive message instances that do not have this header set.

This PR changes the transactional message repositories to set the event ID at the start of the transaction, only if the event ID is not already set. This makes it so the message and outbox repository both receive the same headers. The limitation of this approach (as opposed to EventSaucePHP/EventSauce#247) is that when using an aggregate root repository, the message dispatcher will still receive stale instances. A workaround for that issue could be to simply use a MessageDecorator instead of relying on the message repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant