config/autoload/processes.php
use App\Book\Process\CreateQrcodeComsumer; return [ Mine\Crontab\MineCrontabProcess::class, Hyperf\AsyncQueue\Process\ConsumerProcess::class, CreateQrcodeComsumer::class //增加自定义的异步队列类 ];
由于hyperf只使用自己default的队列 ,所以要重新创建一个
<?php namespace App\Book\Process; use Hyperf\AsyncQueue\Process\ConsumerProcess; use Hyperf\Process\Annotation\Process; #[Process(name: "createQrcode")] class CreateQrcodeComsumer extends ConsumerProcess { protected string $queue = 'createQrcode'; }
然后在config/autoload/async_queue.php
<?php use App\Book\Task\ExportDataJob; return [ 'default' => [ 'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class, 'channel' => 'default', 'timeout' => 2, 'retry_seconds' => [5, 10, 20], 'handle_timeout' => 10, 'processes' => 1, 'concurrent' => [ 'limit' => [ 'default' => 10, ], ], 'redis' => [ 'pool' => 'default', 'queue' => '{default}', ], 'processors' => [ // 在这里添加您的任务处理器类名 // App\Book\Task\ExportDataJob::class, ExportDataJob::class ], ], 'createQrcode' => [ 'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class, 'channel' => 'createQrcode', 'timeout' => 2, 'retry_seconds' => [5, 10, 20], 'handle_timeout' => 10, 'processes' => 1, 'concurrent' => [ 'limit' => [ 'default' => 10, ], ], 'redis' => [ 'pool' => 'default', 'queue' => '{default}', ], 'processors' => [ // 在这里添加您的任务处理器类名 ], ], ];标签:异步,10,default,redis,Hyperf,timeout,class From: https://www.cnblogs.com/sdfgdrg/p/18263527