項目發(fā)版執(zhí)行 php start.php reload 重啟服務時,如果 redis 消費者進程正在處理消息,會導致這些消息丟失。
請問各位大佬,在不改 webman/redis-queue 插件源碼的情況下,有辦法解決這個問題嗎?還是說只能換專業(yè)的 MQTT 服務了?
<?php
namespace app\queue\redis;
use support\Log;
use Webman\RedisQueue\Consumer;
class TestConsume implements Consumer
{
public $queue = 'test-consume';
public $connection = 'default';
public function consume($data)
{
Log::info('@@@@@@@start');
for ($i = 0;$i < 10;$i++) {
sleep(1);
}
Log::info('@@@@@@@end');
}
}
Redis::send('test-consume', []);
tail -f runtime/logs/webman-2025-01-09.log
#輸出
[2025-01-09 09:54:33] default.INFO: @@@@@@@start [] []
php start.php reload
Linux CentOS 7
PHP 8.2.22
Webman-framework v1.5.24
webman/redis-queue v1.3.2
Redis Version: 7.0.11
webman插件:
rabbitmq http://wtbis.cn/plugin/67
redis-stream http://wtbis.cn/plugin/69
workerman組件:
rabbitmq http://wtbis.cn/doc/workerman/components/workerman-rabbitmq.html
mqtt http://wtbis.cn/doc/workerman/components/workerman-mqtt.html
以上都支持ack機制,防止丟失數(shù)據(jù)