diff --git a/controller.rst b/controller.rst index 55c2a92ff9d..61d5f6c395a 100644 --- a/controller.rst +++ b/controller.rst @@ -747,9 +747,6 @@ there are constraint violations: )] UploadedFile $document -.. versionadded:: 7.1 - - The ``#[MapUploadedFile]`` attribute was introduced in Symfony 7.1. .. _controller_map-request-header: diff --git a/messenger.rst b/messenger.rst index 78962530d2f..aad5f64534f 100644 --- a/messenger.rst +++ b/messenger.rst @@ -956,6 +956,49 @@ properties in the ``reset()`` method. If you don't want to reset the container, add the ``--no-reset`` option when running the ``messenger:consume`` command. +Custom Message Execution Strategy +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 8.1 + + The ``MessageExecutionStrategyInterface`` was introduced in Symfony 8.1. + +By default, the worker processes messages synchronously using +:class:`Symfony\\Component\\Messenger\\Execution\\SyncMessageExecutionStrategy`. +You can customize how messages are executed by implementing +:class:`Symfony\\Component\\Messenger\\Execution\\MessageExecutionStrategyInterface` +and passing it to the ``Worker`` constructor:: + + use Symfony\Component\Messenger\Envelope; + use Symfony\Component\Messenger\Execution\MessageExecutionStrategyInterface; + + class MyCustomExecutionStrategy implements MessageExecutionStrategyInterface + { + public function execute(Envelope $envelope, string $transportName, callable $onHandled): void + { + // custom execution logic (e.g. parallel processing) + } + + public function shouldPauseConsumption(): bool + { + return false; + } + + public function wait(callable $onHandled): bool + { + return false; + } + + public function flush(callable $onHandled, bool|float $force = false): bool + { + return false; + } + + public function shutdown(): void + { + } + } + .. _messenger-retries-failures: Rate Limited Transport