nasustop/hapi-queue

3.0.2 2023-12-30 10:10 UTC

This package is auto-updated.

Last update: 2024-10-30 02:16:20 UTC


README

hyperf的队列组件,兼容hyperf/async-queuehyperf/amqp

安装

composer require nasustop/hapi-queue

声称配置文件

php bin/hyperf.php vendor:publish nasustop/hapi-queue

调用队列的方式

$job = new DemoJob(['name' => 'hapi']);
(new Producer($job))->onQueue('test')->dispatcher();

监听队列

命令行

php bin/hyperf.php hapi:queue:work [queue]

Process进程

# 新建process文件DemoProcess.php
# queue配置文件中设置了几个队列,就建立几个process文件,$queue 为配置中的队列名称

<?php

namespace App\Demo;

use Nasustop\HapiQueue\Consumer;

class DemoConsumer extends Consumer
{
    protected string $queue = 'default';
}

# 将DemoProcess加入到process配置文件中
# cat config/autoload/processes.php
<?php

return [
    App\Process\Queue\QueueDefaultProcess::class,
];