$exceptions =
[];
$alreadyHandled = false;
foreach ($this->handlersLocator->
getHandlers($envelope) as $handlerDescriptor) { if ($this->
messageHasAlreadyBeenHandled($envelope,
$handlerDescriptor)) { $alreadyHandled = true;
continue;
} try { $handler =
$handlerDescriptor->
getHandler();
$batchHandler =
$handlerDescriptor->
getBatchHandler();
/** @var AckStamp $ackStamp */
if ($batchHandler &&
$ackStamp =
$envelope->
last(AckStamp::
class)) { $ack =
new Acknowledger(get_debug_type($batchHandler),
static function D\Throwable
$e = null,
$result = null
) use ($envelope,
$ackStamp,
$handlerDescriptor) { if (null !==
$e) { $e =
new HandlerFailedException($envelope,
[$e]);
} else { $envelope =
$envelope->
with(HandledStamp::
fromDescriptor($handlerDescriptor,
$result));
} $ackStamp->
ack($envelope,
$e);
});