From 63fc4e0fbe5bf2f1c2d6535c8a5a5f6a469f2c93 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Wed, 26 Feb 2025 21:51:36 +0100 Subject: [PATCH] [Messenger] Priority support for Beanstalkd bridge Adds explanation about the new `BeanstalkdPriorityStamp` introduced by https://github.com/symfony/symfony/pull/59273 Fixes https://github.com/symfony/symfony-docs/issues/20513 --- messenger.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/messenger.rst b/messenger.rst index de72419aa9c..a9270ae1673 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1789,6 +1789,29 @@ The transport has a number of options: Keepalive support, using the ``--keepalive`` option, was added in Symfony 7.2. +When using the Beanstalkd transport in Symfony Messenger, you can now set the priority of the messages being dispatched. +This allows you to control the order in which the messages are processed, with lower values indicating higher priority. + +To configure the priority, use the ``Symfony\Component\Messenger\Bridge\Beanstalkd\Transport\BeanstalkdPriorityStamp`` +when dispatching a message: + +.. code-block:: php + + use App\Message\SomeMessage; + use Symfony\Component\Messenger\Stamp\BeanstalkdPriorityStamp; + + $this->bus->dispatch(new SomeMessage('some data'), [ + new BeanstalkdPriorityStamp(0), // Highest priority + ]); + +As defined by the Beanstalkd protocol, the priority value must be an integer between 0 (highest priority) and 2**32 (lowest priority). + +If no priority is specified, the default value ``1024`` will be used. + +.. versionadded:: 7.3 + + ``BeanstalkdPriorityStamp`` support was added in Symfony 7.3. + .. _messenger-redis-transport: Redis Transport