// avoid success message if nothing was processed
if (1 <=
$count) { $io->
success('All failed messages have been handled or removed!'
);
} } private function runWorker(string
$failureTransportName, ReceiverInterface
$receiver, SymfonyStyle
$io, bool
$shouldForce): int
{ $count = 0;
$listener =
function DWorkerMessageReceivedEvent
$messageReceivedEvent) use ($io,
$receiver,
$shouldForce, &
$count) { ++
$count;
$envelope =
$messageReceivedEvent->
getEnvelope();
$this->
displaySingleMessage($envelope,
$io);
if ($envelope->
last(MessageDecodingFailedStamp::
class)) { throw new \
RuntimeException(sprintf('The message with id "%s" could not decoded, it can only be shown or removed.',
$this->
getMessageId($envelope) ?? '?'
));
} $shouldHandle =
$shouldForce || 'retry' ===
$io->
choice('Please select an action',
['retry', 'delete'
], 'retry'
);
if ($shouldHandle) { return;
}