If you're using more than one consumers in your configs, consider using multiple_consumers config option instead.


Individual version


old_sound_rabbit_mq:
connections:
.....
producers:
order_create_bmw:
connection: default
exchange_options: { name: order_create_ex, type: direct }
queue_options:
name: order_create_bmw_qu
routing_keys:
- bmw
order_create_audi_mercedes:
connection: default
exchange_options: { name: order_create_ex, type: direct }
queue_options:
name: order_create_audi_mercedes_qu
routing_keys:
- audi
- mercedes
consumers:
order_create_bmw:
connection: default
exchange_options: { name: order_create_ex, type: direct }
queue_options:
name: order_create_bmw_qu
routing_keys:
- bmw
callback: application_frontend.consumer.order_create_bmw
order_create_audi_mercedes:
connection: default
exchange_options: { name: order_create_ex, type: direct }
queue_options:
name: order_create_audi_mercedes_qu
routing_keys:
- audi
- mercedes
callback: application_frontend.consumer.order_create_audi_mercedes

This is how you would run individual consumers.


# Consumes only bmw messges
$ app/console rabbitmq:consumer -m 100 order_create_bmw
$ app/console rabbitmq:consumer -m 100 order_create_bmw

# Consumes only audi and mercedes messges
$ app/console rabbitmq:consumer -m 100 order_create_audi_mercedes
$ app/console rabbitmq:consumer -m 100 order_create_audi_mercedes

Multiple consumers version


old_sound_rabbit_mq:
connections:
.....
producers:
order_create_bmw:
connection: default
exchange_options: { name: order_create_ex, type: direct }
queue_options:
name: order_create_bmw_qu
routing_keys:
- bmw
order_create_audi_mercedes:
connection: default
exchange_options: { name: order_create_ex, type: direct }
queue_options:
name: order_create_audi_mercedes_qu
routing_keys:
- audi
- mercedes
multiple_consumers:
order:
connection: default
exchange_options: { name: order_create_ex, type: direct }
queues:
order_create_bmw:
name: order_create_bmw_qu
callback: application_frontend.consumer.order_create_bmw
routing_keys:
- bmw
order_create_audi_mercedes:
name: order_create_audi_mercedes_qu
callback: application_frontend.consumer.order_create_audi_mercedes
routing_keys:
- audi
- mercedes

As you can see below, you don't have to run individual consumers "bmw" and "audi/mercedes" messages.


# Consumes all "bmw", "audi" and "mercedes" messages
$ app/console rabbitmq:multiple-consumer -m 100 order
$ app/console rabbitmq:multiple-consumer -m 100 order