Open
Description
Description
Provide possibility to prioritize messages of the same type by introduction of PriorityStamp
.
Messenger currently offers prioritized transports. It only works fine when you define priority per message type.
Currently I'm working on a project where we needed a priority queue. Requests coming from certain users should be handled first. It is possible to do so:
# Fragment of messenger.yaml: define x-max-priority for RabbitMQ queue via config
framework:
messenger:
transports:
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
queues:
app.messenger:
arguments:
x-max-priority: 255
$stamp = new AmqpStamp(null, \AMQP_NOPARAM, ['priority' => 127]);
$this->eventBus->dispatch($event, [$stamp]);
But there are at least two problems here:
- We are forced to decide routing key & AMQP params. Message producer should not be aware of these details
- It's not adapter-agnostic. Beanstalkd also supports priority, but is hardcoded and cannot be configured
Currently working on a PR, will submit it soon.