Skip to content

Commit 34ac7c7

Browse files
authored
Merge pull request #558 from MohamedHuzien/master
priority queue documentation
2 parents 4971b13 + 3ba9cd8 commit 34ac7c7

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
@@ -687,6 +687,38 @@ To enable [direct reply-to clients](https://www.rabbitmq.com/direct-reply-to.htm
687687

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

690+
### Priority queue ###
691+
692+
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).
693+
The implementation supports a limited number of priorities: 255. Values between 1 and 10 are recommended. [Check documentation](https://www.rabbitmq.com/priority.html)
694+
695+
here is how you can declare a priority queue
696+
697+
```yml
698+
consumers:
699+
upload_picture:
700+
connection: default
701+
exchange_options: {name: 'upload-picture', type: direct}
702+
queue_options: {name: 'upload-picture', arguments: {'x-max-priority': ['I', 10]} }
703+
callback: upload_picture_service
704+
705+
```
706+
707+
if `upload-picture` queue exist before you must delete this queue before you run `rabbitmq:setup-fabric` command
708+
709+
710+
Now let's say you want to make a message with high priority, you have to publish the message with this additional information
711+
712+
```php
713+
public function indexAction()
714+
{
715+
$msg = array('user_id' => 1235, 'image_path' => '/path/to/new/pic.png');
716+
$additionalProperties = ['priority' => 10] ;
717+
$routing_key = '';
718+
$this->get('old_sound_rabbit_mq.upload_picture_producer')->publish(serialize($msg), $routing_key , $additionalProperties );
719+
}
720+
```
721+
690722
### Multiple Consumers ###
691723

692724
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)