redis队列 无法消费

macho

问题描述

redis队列 出现 "Call to a member function connection() on null"

不是所有的消息都出现,偶发性的 且频率很高。

投递消息时 返回值为true

程序代码或配置

Redis::send($name, $param, $delay)

plugin/webman/redis-queue/process.php

return [
    'consumer'  => [
        'handler'     => Webman\RedisQueue\Process\Consumer::class,
        'count'       => getenv('REDIS_QUEUE_COUNT') ?? 8, // 可以设置多进程同时消费
        'constructor' => [
            // 消费者类目录
            'consumer_dir' => app_path() . '/queue/redis'
        ]
    ]
];

plugin/webman/redis-queue/redis.php

return [
    'default' => [
        'host' => 'redis://'.getenv('REDIS_HOST','redis://127.0.0.1:6379').':'.getenv('REDIS_PORT','6379'),
//        'host' => 'redis://r-j6c3evt2hq7z1x89h0pd.redis.rds.aliyuncs.com:6379',
        'options' => [
            'auth' => getenv('REDIS_PASSWORD',''),            // 密码,字符串类型,可选参数
            'db' => getenv('REDIS_QUEUE_DB',0),                     // 数据库
            'prefix' => '',                                                         // key 前缀
            'max_attempts'  => getenv('REDIS_QUEUE_MAX',3), // 消费失败后,重试次数
            'retry_seconds' => getenv('REDIS_QUEUE_RETRY',3), // 重试间隔,单位秒
        ]
    ],
];

截图

操作系统环境及workerman/webman等具体版本

截图

composer.json

"php": ">=8.1",
    "workerman/webman-framework": "~2.1",
    "workerman/crontab": "^1.0",
    "workerman/workerman": "~5.1",
    "workerman/http-client": "3.0.2",
    "webman/redis-queue": "^1.3",
    "webman/rate-limiter": "^1.1",
    "webman/database": "~2.1",
    "webman/log": "~2.1",
    "webman/cache": "~2.1",
    "webman/redis": "~2.1",
    "monolog/monolog": "^2.0",
    "vlucas/phpdotenv": "^5.6",
    "illuminate/redis": "^10.0",
    "illuminate/pagination": "^10.0",
    "illuminate/events": "^10.0",
    "symfony/var-dumper": "^6.0",
    "laravel/serializable-closure": "2.0",
    "webman/console": "1.2.24",
    "topthink/think-template": "^3.0",
    "aliyuncs/oss-sdk-php": "^2.7",
    "firebase/php-jwt": "^6.10",
    "intervention/image": "^2.7",
    "symfony/translation": "^6.4",
    "phpmailer/phpmailer": "^6.9",
    "revolt/event-loop": "1.0.1",
    "endroid/qr-code": "^5.1",
    "guzzlehttp/guzzle": "^7.9",
    "picqer/php-barcode-generator": "^2.4",
    "ext-gd": "*",
    "ext-pdo": "*",
    "smalot/pdfparser": "^2.9",
    "geoip2/geoip2": "^3.1",
    "phpoffice/phpspreadsheet": "^3.7"

composer 更新
截图

243 1 0
1个回答

对比下版本 https://github.com/webman-php/redis-queue

webman/redis-queue webman/redis webman/database 都升级到最新版

  • macho 8天前

    不行啊 老大 更新后还是偶有发生.

  • walkor 8天前

    更新完重启。
    如果还有问题把调用栈记录下,否则不知道哪个文件那行报错。

  • macho 8天前

    解决了 我是把redis队列数据库配置 的 db=0 修改成了 db=1

x
 
1
  • |
  • |
  • |
×
🔝