Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Add message priority feature for Messenger #41573

Open
@kozlice

Description

@kozlice

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:

  1. We are forced to decide routing key & AMQP params. Message producer should not be aware of these details
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions