18910140161

webman监听MNS消息队列,无法实时消费,每次消费中间间隔不定的时间?

顺晟科技

2022-10-19 10:23:10

152

问题一:
webman监听MNS消息队列,无法实时消费,每次消费中间间隔不定的时间
数据库的执行几乎不耗费时间,不是数据库等待时间
请问还可以从哪些方面去找问题

问题二:
报这个错误 worker[task:2630] exit with status 9

首先开自定义进程


   public function onWorkerStart()
    {

        $endPoint = '1';
        $accessId = "2";
        $accessKey = "3";

         //队列名称
        $queueName = "buyorder-settle";
        $client = new Client($endPoint, $accessId, $accessKey);
        $queue = $client->getQueueRef($queueName);

        pcntl_signal(SIGINT, function () {
            Worker::stopAll();
        });

        while (true) {
            try {

               $t1_start=time();

               $res = $queue->receiveMessage(1);
                $receiptHandle = $res->getReceiptHandle();
                //接收消息
                $r = $res->getMessageBody();

                    $update_o = [
                        'buyorder_status' => "finish",
                    ];
                    $r1 = Db::name("buy_order")
                        ->where("buyorder_id", $r['order_id'])->update($update_o);

                    if ($r1) {
                          $delete_action = $queue->deleteMessage($receiptHandle);
                          $haoshi=time()-$t1_start;
                          print(date('Y-m-d H:i:s')."---完成--耗时".$haoshi."s"."\r\n");
                          pcntl_signal_dispatch();
                    }

            } catch (\Throwable $throwable) {

            }
        }

    }

MNS应该如何填写参数
image.png

相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航