Up till now, Enqueue consumption performance from multiple queues within one process has been poor. QueueConsumer used round robin algorithm to fetch messages from queues in combination with the blocking receive method.

The worst case scenario is when you have lots of empty queues and a few with messages. For example, It consumes from five queues and only one has messages and the receive timeout is one second. In this case, it would consume messages one per four seconds. The performance degrades a hundred times. It affected all transports except AMQP.

Since Enqueue 0.8.35 supports SubscriptionConsumer. The feature has to be enabled explicitly on 0.8.x version and will be the default approach since 0.9. It improves dramatically performance of the worst case scenario and opens a room for further improvements, for instance, Doctrine DBAL transport can fetch messages from multiple queues at one go.

To try it out, make sure you have at least enqueue\enqueue of 0.8.35 version.

QueueConsumer:

<?php



use Enqueue\Consumption\QueueConsumer;



/** @var \Interop\Queue\PsrContext $context */



$queueConsumer = new QueueConsumer($context);

$queueConsumer->enableSubscriptionConsumer(true);

SimpleClient:

<?php



use Enqueue\SimpleClient\SimpleClient;



$client = new SimpleClient('null:');

$client->getQueueConsumer()->enableSubscriptionConsumer(true);

Symfony:

# app/config/services.yaml

# composer upd enqueue/enqueue-bundle:^0.8.35 enqueue.queue_consumer.enable_subscription_consumer: true

Enjoy!