Skip to content

Latest commit

 

History

History
82 lines (57 loc) · 2.26 KB

queues.md

File metadata and controls

82 lines (57 loc) · 2.26 KB

Laravel Queue. Quick tour.

The LaravelQueue package allows to use queue-interop compatible transports the Laravel way. I suppose you already installed and configured the package so let's look what you have to do to make queue work.

Configure

You have to add a connector to config/queues.php file. The driver must be interop.

<?php

// config/queue.php

return [
    // uncomment to set it as default
    // 'default' => env('QUEUE_DRIVER', 'interop'),
    
    'connections' => [
        'interop' => [
            'driver' => 'interop',
            'connection_factory_class' => \Enqueue\Fs\FsConnectionFactory::class,
            
            // the factory specific options
            'dsn' => 'file://'.realpath(__DIR__.'/../storage').'/enqueue',
        ],
    ],
];

Usage

Same as standard Laravel Queues

Send message example:

<?php

$job = (new \App\Jobs\EnqueueTest())->onConnection('interop');

dispatch($job);

Consume messages:

$ php artisan queue:work interop

Amqp interop

While interop connector can send\consume messages from any queue interop compatible transports. But it does not support some AMQP specific features, such as queue declaration and delays. To cover those cases the package provides a AmqpQueue. It can work with any amqp interop compatible trnasport, for example enqueue/amqp-bunny. Here's how it could be configured:

<?php

// config/queue.php

return [
    // uncomment to set it as default
    // 'default' => env('QUEUE_DRIVER', 'interop'),
    
    'connections' => [
        'interop' => [
            'driver' => 'amqp_interop',
            'connection_factory_class' => \Enqueue\AmqpBunny\AmqpConnectionFactory::class,
            
            // connects to localhost
            'dsn' => 'amqp://',
            
            // could be "rabbitmq_dlx", "rabbitmq_delay_plugin", instance of DelayStrategy interface or null 
            // 'delay_strategy' => 'rabbitmq_dlx' 
        ],
    ],
];

back to index