redis隊列 出現(xiàn) "Call to a member function connection() on null"
不是所有的消息都出現(xiàn),偶發(fā)性的 且頻率很高。
投遞消息時 返回值為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, // 可以設(shè)置多進(jìn)程同時消費
'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',''), // 密碼,字符串類型,可選參數(shù)
'db' => getenv('REDIS_QUEUE_DB',0), // 數(shù)據(jù)庫
'prefix' => '', // key 前綴
'max_attempts' => getenv('REDIS_QUEUE_MAX',3), // 消費失敗后,重試次數(shù)
'retry_seconds' => getenv('REDIS_QUEUE_RETRY',3), // 重試間隔,單位秒
]
],
];
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 更新