Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Yii2 Queue Laravel Package

yiisoft/yii2-queue

Yii2 Queue runs tasks asynchronously via pluggable queue backends: DB, Redis, RabbitMQ/AMQP, Beanstalk, ActiveMQ, and Gearman. Define jobs as classes implementing JobInterface and push them to the queue for background processing.

View on GitHub
Deep Wiki
Context7

AMQP Interop

The driver works with RabbitMQ queues.

In order for it to work you should add any amqp interop compatible transport to your project, for example enqueue/amqp-lib package.

Advantages:

Configuration example:

return [
    'bootstrap' => [
        'queue', // The component registers 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:',
        ],
    ],
];

Console

Console is used to listen and process queued tasks.

yii queue/listen

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 command is properly daemonized via supervisor or systemd.

listen command has options:

  • --verbose, -v: 详细模式执行作业。如果启用,将打印每个作业的执行结果。
  • --isolate: 隔离模式。将在子进程中执行作业。
  • --color: 在详细模式下高亮显示输出结果。

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope