Reputation: 394
I think I have simple question but I can't answer on it: How can I run many consumers at once? For example I have 3 consumers
consumers:
rename_image_folder: ...
update_customer: ...
create_protocol: ...
and how can I run them at once? I have to open 3 console window and run them? But in our project we have 10 microservice api and each one have at least one consumer. How can I work with it?
I believe that I that we have a way how to make it. For example, I have different routing_key, and I have to write different methods (or services) to processing queues. Maybe there is another way to processing it.
It will be very good if you apply an example please. Thanks!
Upvotes: 2
Views: 2428
Reputation: 3698
You need to use a bundle like this one and install supervisord on your server. The bundle will handle creating supervisord profiles from your rabbitmq settings, keeping your different consumers alive automatically.
I've got it working very stably with this bundle and php-amqplib/rabbitmq-bundle
Upvotes: 1
Reputation: 39390
Different consumer would say different php process, this mean that you can scale up increasing the number of consumer adding more php process that consume message of the queue.
I suggest you to use a tool like Supervisord in order to control the number of php process and take care of the status of the process.
As example, you could configure a simple supervisord process with the number of php process (the numprocs
element):
[supervisord]
logfile = /tmp/supervisord.log
logfile_maxbytes = 10MB
directory = %(here)s
pidfile = /tmp/supervisord.pid
[program:todo]
command = php /var/www/symfony/bin/console rabbitmq:consumer -w sync
autostart = true
autorestart = true
numproc=5
Hope this help
Upvotes: 2