Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Messenger/DoctrineTransactionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel

return $envelope;
} catch (\Throwable $exception) {
$entityManager->getConnection()->rollBack();
$this->tryRollBackTransaction($entityManager, $exception);

if ($exception instanceof HandlerFailedException) {
// Remove all HandledStamp from the envelope so the retry will execute all handlers again.
Expand All @@ -45,4 +45,13 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel
throw $exception;
}
}

private function tryRollBackTransaction(EntityManagerInterface $entityManager, \Throwable|\Exception $exception): void
{
try {
$entityManager->getConnection()->rollBack();
} catch (\Throwable $doctrineException) {
throw new HandlerFailedException($doctrineException->getMessage(), previous: $exception);
}
}
}