Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

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