Reputation: 597
I'm currently trying to use RabbitMQ ( with the excellent RabbitMQBundle ) to process a lot of async work.
The goal is to have one queue to publish messages of the same type and to have X workers on multiple servers to peek messages in the same time.
Each worker have to peek one message, do the job then peek another message etc..
Here my conf :
old_sound_rabbit_mq:
connections:
default:
host: 'localhost'
port: 5672
user: 'myuser'
password: 'mypassword'
vhost: '/'
lazy: false
producers:
generate_report:
connection: default
exchange_options: { name: 'gen_report', type: fanout }
consumers:
generate_report:
connection: default
exchange_options: { name: 'gen_report', type: fanout }
queue_options: { name: 'gen_report' }
callback: generator.report.consumer
In my consumer, i have an entry in a logfile and a sleep of 120 seconds.
I started php app/console rabbitmq:consumer generate_report like 10 times, but when i look my log file i have only message each 120 and the goal is to have 10 !
I've also tried to set my queue as topic or direct with the same results.
I don't understand what i'm doing wrong :'(
Thanks in advance
Kind regards
Upvotes: 2
Views: 2765
Reputation: 4254
I have experienced the same issue. What you can do is set the number of messages fetched to 1.
$channel->basic_qos(null, 1, null);
http://www.rabbitmq.com/tutorials/tutorial-two-php.html , see Fair dispatch section.
Upvotes: 1