天天看点

Hyperf 高性能PHP协程框架实战(十二)Redis异步队列

       Hyperf的Redis异步队列只提供一种异步处理和异步延时处理的能力,并不能严格地保证消息的持久化、不支持完备的ACK应答机制。

      Composer安装:

composer require hyperf/async-queue
           

      配置文件 config/autoload/async_queue.php :

<?php

declare(strict_types=1);

return [
    'default' => [
        'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class,
        'redis' => [ //redis 连接池
            'pool' => 'default'
        ],
        'channel' => 'queue', //队列前缀
        'timeout' => 2, //pop 消息的超时时间
        'retry_seconds' => 5, //失败后重新尝试间隔(也可以传数组如:[1, 5, 10, 20] , 代表根据重试次数相应修改重试时间)
        'handle_timeout' => 10, //消息处理超时时间
        'processes' => 1, //消费进程数
        'concurrent' => [ //同时处理消息数
            &#