diff --git a/guides/plugins/plugins/framework/message-queue/add-message-to-queue.md b/guides/plugins/plugins/framework/message-queue/add-message-to-queue.md index 68b2c8ad25..fcc294c147 100644 --- a/guides/plugins/plugins/framework/message-queue/add-message-to-queue.md +++ b/guides/plugins/plugins/framework/message-queue/add-message-to-queue.md @@ -10,7 +10,7 @@ nav: ## Overview ::: warning -Parts of this guide refer to the `low_priority` queue and the corresponding `AsyncLowPriorityMessageInterface` which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist. +Parts of this guide refer to the `low_priority` queue and the corresponding `LowPriorityMessageInterface` which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist. ::: In this guide you'll learn how to create a message and add it to the queue. @@ -27,7 +27,7 @@ As most guides, this guide is also built upon the [Plugin base guide](../../plug ## Create a message -First, we have to create a new message class in the directory `/MessageQueue/Message`. In this example, we create a `SmsNotification` that contains a string with content. By default, all messages are handled synchronously, to change the behavior to asynchronously we have to implement the `AsyncMessageInterface` interface. For messages which should also be handled asynchronously but with a lower priority, you have to implement the `AsyncLowPriorityMessageInterface` interface. +First, we have to create a new message class in the directory `/MessageQueue/Message`. In this example, we create a `SmsNotification` that contains a string with content. By default, all messages are handled synchronously, to change the behavior to asynchronously we have to implement the `AsyncMessageInterface` interface. For messages which should also be handled asynchronously but with a lower priority, you have to implement the `LowPriorityMessageInterface` interface. Here's an example: @@ -98,6 +98,45 @@ public function sendMessage(string $message): void } ``` +## Lower the priority for specific async messages + +You might consider using the new `low_priority` queue if you are dispatching messages that do not need to be handled immediately. To configure specific messages to be transported via the `low_priority` queue, you need to either adjust the routing or implement the `LowPriorityMessageInterface` as already mentioned: + +```yaml +# config/packages/framework.yaml +framework: + messenger: + routing: + 'Your\Custom\Message': low_priority +``` + +## Override transport for specific messages + +If you explicitly configure a message to be transported via the `async` (default) queue, even though it implements the `LowPriorityMessageInterface` which would usually be transported via the `low_priority` queue, the transport is overridden for this specific message. + +Example: +```php +// /src/MessageQueue/Message/LowPriorityMessage.php +