Skip to content

Commit 3ba9cd8

Browse files
committed
add priority queue documentation in README file
1 parent cf67ada commit 3ba9cd8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,38 @@ To enable [direct reply-to clients](https://www.rabbitmq.com/direct-reply-to.htm
662662

663663
This option will use pseudo-queue __amq.rabbitmq.reply-to__ when doing RPC calls. On the RPC server there is no modification needed.
664664

665+
### Priority queue ###
666+
667+
RabbitMQ has priority queue implementation in the core as of version 3.5.0. Any queue can be turned into a priority one using client-provided optional arguments (but, unlike other features that use optional arguments, not policies).
668+
The implementation supports a limited number of priorities: 255. Values between 1 and 10 are recommended. [Check documentation](https://www.rabbitmq.com/priority.html)
669+
670+
here is how you can declare a priority queue
671+
672+
```yml
673+
consumers:
674+
upload_picture:
675+
connection: default
676+
exchange_options: {name: 'upload-picture', type: direct}
677+
queue_options: {name: 'upload-picture', arguments: {'x-max-priority': ['I', 10]} }
678+
callback: upload_picture_service
679+
680+
```
681+
682+
if `upload-picture` queue exist before you must delete this queue before you run `rabbitmq:setup-fabric` command
683+
684+
685+
Now let's say you want to make a message with high priority, you have to publish the message with this additional information
686+
687+
```php
688+
public function indexAction()
689+
{
690+
$msg = array('user_id' => 1235, 'image_path' => '/path/to/new/pic.png');
691+
$additionalProperties = ['priority' => 10] ;
692+
$routing_key = '';
693+
$this->get('old_sound_rabbit_mq.upload_picture_producer')->publish(serialize($msg), $routing_key , $additionalProperties );
694+
}
695+
```
696+
665697
### Multiple Consumers ###
666698

667699
It's a good practice to have a lot of queues for logic separation. With a simple consumer you will have to create one worker (consumer) per queue and it can be hard to manage when dealing

0 commit comments

Comments
 (0)