Cancel delayed message if handler fails
This commit is contained in:
parent
35c76a385d
commit
1f5c8a6790
@ -81,12 +81,16 @@ class DispatchAfterCurrentBusMiddleware implements MiddlewareInterface
|
|||||||
// "Root dispatch" call is finished, dispatch stored messages.
|
// "Root dispatch" call is finished, dispatch stored messages.
|
||||||
$exceptions = [];
|
$exceptions = [];
|
||||||
while (null !== $queueItem = array_shift($this->queue)) {
|
while (null !== $queueItem = array_shift($this->queue)) {
|
||||||
|
// Save how many messages are left in queue before handling the message
|
||||||
|
$queueLengthBefore = \count($this->queue);
|
||||||
try {
|
try {
|
||||||
// Execute the stored messages
|
// Execute the stored messages
|
||||||
$queueItem->getStack()->next()->handle($queueItem->getEnvelope(), $queueItem->getStack());
|
$queueItem->getStack()->next()->handle($queueItem->getEnvelope(), $queueItem->getStack());
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
// Gather all exceptions
|
// Gather all exceptions
|
||||||
$exceptions[] = $exception;
|
$exceptions[] = $exception;
|
||||||
|
// Restore queue to previous state
|
||||||
|
$this->queue = \array_slice($this->queue, 0, $queueLengthBefore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user