I have a symfony project wrapped in docker and a Redis queue configured.
Configurations:
messenger.yaml
parameters:
env(CONSUMER_ID): '0'
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async_priority_high:
dsn: 'redis://%env(REDIS_QUEUE_NAME)%:6379/messages/symfony/consumer-%env(CONSUMER_ID)%&auth=%env(REDIS_PASSWORD)%'
options:
redeliver_timeout: 10000
group: high
retry_strategy:
max_retries: 3
# milliseconds delay
delay: 2000
# causes the delay to be higher before each retry
# e.g. 1 second delay, 2 seconds, 4 seconds
multiplier: 2
max_delay: 0
async_priority_low:
dsn: 'redis://%env(REDIS_QUEUE_NAME)%:6379/messages/symfony/consumer-%env(CONSUMER_ID)%&auth=%env(REDIS_PASSWORD)%'
options:
redeliver_timeout: 10000
group: low
# default configuration
retry_strategy:
max_retries: 3
# milliseconds delay
delay: 2000
# causes the delay to be higher before each retry
# e.g. 1 second delay, 2 seconds, 4 seconds
multiplier: 2
max_delay: 0
failed: 'doctrine://default?queue_name=failed'
routing:
'App\Message\MessageHighPriority': async_priority_high
'App\Message\MessageLowPriority': async_priority_low
Handlers:
<?php
namespace App\MessageHandler;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
final class Handler implements MessageHandlerInterface
{
public function __construct(...)
{
...
}
public function __invoke(MessageHighPriority $message)
{
...
}
}
But when I run the command
bin/console messenger:consume async_priority_high -vv
I see that MessagePriorityLow is processed regardless of which receiver I run and in what priority, that is, if I have both messages in the queue then when I run the command
bin/console messenger:consume async_priority_high async_priority_high -vv
first processed those messages that entered the queue first
In addition, if I explicitly specify in the Hanlker from_transport => async_priority_low for low priority, and run the command
bin/console messenger:consume async_priority_high async_priority_high -vv
I get the error that there is no handler for async_priority_low
What am I doing wrong?