Skip to content

Commit 4e129f6

Browse files
committed
- Altered the default priority levels when using this feature
1 parent 8703cae commit 4e129f6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Optionally add queue options to the config of a connection.
7979
Every queue created for this connection, get's the properties.
8080

8181
When you want to prioritize messages when they were delayed, then this is possible by adding extra options.
82-
- When max-priority is omitted, the max priority is set with 100.
82+
- When max-priority is omitted, the max priority is set with 2 when used.
8383

8484
```php
8585
'connections' => [
@@ -93,7 +93,7 @@ When you want to prioritize messages when they were delayed, then this is possib
9393
// ...
9494

9595
'prioritize_delayed_messages' => false,
96-
'queue_max_priority' => 100,
96+
'queue_max_priority' => 10,
9797
],
9898
],
9999
],

src/Queue/RabbitMQQueue.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ protected function getQueueArguments(string $destination): array
537537
{
538538
$arguments = [];
539539

540+
// Messages without a priority property are treated as if their priority were 0.
541+
// Messages with a priority which is higher than the queue's maximum, are treated as if they were
542+
// published with the maximum priority.
540543
if ($this->isPrioritizeDelayed()) {
541544
$arguments['x-max-priority'] = $this->getQueueMaxPriority();
542545
}
@@ -577,13 +580,16 @@ protected function isPrioritizeDelayed(): bool
577580
}
578581

579582
/**
580-
* Returns a integer with a default of '100' for when using prioritization on delayed messages.
583+
* Returns a integer with a default of '2' for when using prioritization on delayed messages.
584+
* If priority queues are desired, we recommend using between 1 and 10.
585+
* Using more priority layers, will consume more CPU resources and would affect runtimes.
581586
*
587+
* @see https://www.rabbitmq.com/priority.html
582588
* @return int
583589
*/
584590
protected function getQueueMaxPriority(): int
585591
{
586-
return intval(Arr::get($this->options, 'queue_max_priority') ?: 100);
592+
return intval(Arr::get($this->options, 'queue_max_priority') ?: 2);
587593
}
588594

589595
/**

0 commit comments

Comments
 (0)