You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dispatching domain events after a terminate event with an open rollback transaction might lead to dispatched events which aren't really persisted yet (which contradicts the outbox pattern).
I stumbled upon this by accident when I saw a failing command producing Symfony messenger entries and solved it with this modified version of \Headsnet\DomainEventsBundle\EventSubscriber\PublishDomainEventSubscriber::publishEvents
(an instance of EntityManager is additionally injected via constructor)
privatefunctionpublishEvents(): void
{
// We definitely should not publish events during an open transaction (as events might not be persisted yet)if ($this->entityManager->getConnection()->isTransactionActive()) {
return;
}
foreach ($this->eventStore->allUnpublished() as$event) {
$this->publishEvent($event);
}
}
Is this the correct solution, or are there any other drawbacks I didn't think about @benr77 ?
The text was updated successfully, but these errors were encountered:
The first idea was to add ->setCacheMode(Cache::MODE_REFRESH) to the query, but that had no effect and I found no other nice way to force a query on the actual database.
Dispatching domain events after a terminate event with an open rollback transaction might lead to dispatched events which aren't really persisted yet (which contradicts the outbox pattern).
I stumbled upon this by accident when I saw a failing command producing Symfony messenger entries and solved it with this modified version of \Headsnet\DomainEventsBundle\EventSubscriber\PublishDomainEventSubscriber::publishEvents
(an instance of EntityManager is additionally injected via constructor)
Is this the correct solution, or are there any other drawbacks I didn't think about @benr77 ?
The text was updated successfully, but these errors were encountered: