RabbitMQ捆绑包:一个队列&;多个工人


RabbitMQ Bundle : One queue & multiple workers

我目前正在尝试使用RabbitMQ(带有出色的RabbitMQBundle)来处理大量异步工作。

目标是让一个队列发布相同类型的消息,并让多个服务器上的X个工作人员同时查看消息。

每个工人都必须偷看一条消息,完成工作后再偷看另一条消息等。

这里是我的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

在我的消费者中,我在日志文件中有一个条目,睡眠时间为120秒。

我启动了php app/console rabbitmq:consumer generate_report大约10次,但当我查看日志文件时,我只收到了每个120条消息,目标是有10条!

我还尝试将队列设置为主题或直接队列,结果相同。

我不明白我做错了什么:

提前感谢

亲切问候

我也遇到过同样的问题。您可以将提取的消息数设置为1。

$channel->basic_qos(null, 1, null);

http://www.rabbitmq.com/tutorials/tutorial-two-php.html,请参阅公平调度部分。