centos7.9,最新webman,按文檔使用隊(duì)列,內(nèi)容如下,即時(shí)隊(duì)列可以正常消費(fèi),延時(shí)隊(duì)列不能正常消費(fèi)。
正常的流程應(yīng)該是當(dāng){redis-queue}-delayed里面的隊(duì)列時(shí)間到指定的延長時(shí)間,就會(huì)將里面的數(shù)據(jù)轉(zhuǎn)移到{redis-queue}-waiting里面,現(xiàn)在我的情況是{redis-queue}-waiting里面的均能正常消費(fèi),但是{redis-queue}-delayed的數(shù)據(jù)一直不處理。 plugin.webman.redis-queue.consumer這個(gè)進(jìn)程是存在的,要不然也不會(huì)只消費(fèi)即時(shí)隊(duì)列的數(shù)據(jù)。
琢磨了一下午。有大神能指點(diǎn)一下嗎?
隊(duì)列投遞
<?php
namespace app\rsapi\v2\controller;
use support\Request;
use Webman\RedisQueue\Redis;
class TestController
{
public function index(Request $request)
{
// 隊(duì)列名
$queue = 'timeout_order_queue';
// 數(shù)據(jù),可以直接傳數(shù)組,無需序列化
$data = ['to' => 'tom@gmail.com', 'content' => 'hello'];
// 投遞消息
Redis::send($queue, $data);
// 投遞延遲消息,消息會(huì)在60秒后處理
Redis::send($queue, $data, 5);
return response('redis queue test');
}
}
隊(duì)列消費(fèi)
<?php
namespace app\queue\redis;
use Webman\RedisQueue\Consumer;
class TimeoutOrderQueue implements Consumer
{
// 要消費(fèi)的隊(duì)列名
public $queue = 'timeout_order_queue';
// 連接名,對(duì)應(yīng) plugin/webman/redis-queue/redis.php 里的連接`
public $connection = 'default';
// 消費(fèi)
public function consume($data)
{
// 無需反序列化
var_export($data);
}
}
redis-server版本是?
redis-server=6.2.4。
我發(fā)現(xiàn)了問題的所在,我有二個(gè)消費(fèi)。
其中A消費(fèi)的$connection='default',為本地redis連接。
其中B消費(fèi)的$connection='master',為遠(yuǎn)程redis連接。
master連接是沒有問題的,可以正常連接,因?yàn)槲沂褂肦edis::connection('master')->send($queue, $data);推送到遠(yuǎn)程redis,是可以查看到Zset的數(shù)據(jù)的。
當(dāng)我B消費(fèi)的$connection='master'時(shí),延時(shí)隊(duì)列,將不能正常消費(fèi),即時(shí)消費(fèi)的沒問題。當(dāng)我將master改為default時(shí),延時(shí)消費(fèi)和即時(shí)消費(fèi)均可正常使用。
正常按道理,如果我的A消費(fèi)連接的是default,跟B消費(fèi)應(yīng)該是不關(guān)聯(lián)的。即使是連接質(zhì)量問題導(dǎo)致連接失敗,那也是B消費(fèi)不能正常消費(fèi)延時(shí)隊(duì)列,為什么會(huì)導(dǎo)致我的A消費(fèi)不能延時(shí)消費(fèi)。
解決了,不明所以,使用命令行生成的,就沒有問題。
php webman redis-queue:consumer TimeoutOrder
我也遇見了相同的問題
本地開發(fā)環(huán)境 win11
有多個(gè)隊(duì)列,order
隊(duì)列使用的數(shù)據(jù)庫是 8
,本地開發(fā)延遲隊(duì)列和即時(shí)隊(duì)列都可正常執(zhí)行。
但是在部署到 linux
環(huán)境的時(shí)候,發(fā)現(xiàn)即時(shí)隊(duì)列可以正常運(yùn)行延遲隊(duì)列沒有跑,不知道什么問題,redis庫也能看到 {redis-queue}-delayed
zset數(shù)據(jù)
后續(xù)調(diào)整redis數(shù)據(jù)庫為 6
就可以了,試了4和5都不行,沒找到具體為啥,就先這樣了...
redis-server版本是 6.0.8