AMQP Interop

This driver works with RabbitMQ queues.

It requires an amqp interop compatible transport, for example the enqueue/amqp-lib package.


Configuration example:

return [
    'bootstrap' => [
        'queue', // The component registers its own console commands
    'components' => [
        'queue' => [
            'class' => \yii\queue\amqp_interop\Queue::class,
            'port' => 5672,
            'user' => 'guest',
            'password' => 'guest',
            'queueName' => 'queue',
            'driver' => yii\queue\amqp_interop\Queue::ENQUEUE_AMQP_LIB,

            // or
            'dsn' => 'amqp://guest:guest@localhost:5672/%2F',

            // or, same as above
            'dsn' => 'amqp:',


A console command is used to execute queued jobs.

yii queue/listen

The listen command launches a daemon which infinitely queries the queue. If there are new tasks they're immediately obtained and executed. This method is most efficient when the command is properly daemonized via supervisor or systemd.

Working with headers in messages

The setMessageHeaders attribute can be used to send random headers to the queue along with the message.

For example:

$queue = Yii::$app->queueTest;
$queue->setMessageHeaders = [
    'header1' => 'header-value1',
    'header2' => 'header-value2',
$queue->push(new TestJob());

Note! Existing headers will not be overwritten by default.