I'm using RabbitMQ (3.8.3 Erlang 22.3.1) for Laravel (6.18.*).
For this I'm using, https://github.com/vyuldashev/laravel-queue-rabbitmq.
With normal queue and consumer, everything is working fine. To prioritize messages, I've defined multiple queues with 0-3 as suffix in the queue names. I'm routing the jobs to different queues by manually calculating the total jobs.
Using this approach, for different tasks, I needed to create more queues with priorities on the name. Creating queues with 0-3 in the queue names does not seem scalable.
Now I'm trying to set priority per message. For that I tried to use priority property in AMQPMessage as:
$msg = new AMQPMessage("Hello World!", array(
'delivery_mode' => 2,
'priority' => 1,
'timestamp' => time(),
'expiration' => strval(1000 * (strtotime('+1 day midnight') - time() - 1))
));
I tried multiple messages with different priorities but priority doesn't seem to work at all.
- I set
x-max-priorityon queue - I set
priorityto 1 for a AMQPMessage and dispatched 100K message from one terminal - Same time I dispatched another set of message of 10 with
priority2
But the consumer doesn't seem to consume message with priority 2.
Any idea what mistake am I doing? Please let me know if there's anything to set priorities per message so that consumer picks them first.