Laravel 4队列作业未从队列

时间:2018-04-16 10:35:12

标签: php laravel-4

我在Laravel v4.2工作。我有一个队列作业,我在后台运行这个队列作业进程成功,但在成功后没有从队列中删除,并再次调用第二次尝试并运行由于我的作业尝试条件验证。但它应该从队列中删除。因为它在第一次尝试时成功处理。下面是我编码的代码

public function moveAndDeletePost($job, $data) {
        Log::useDailyFiles(storage_path() . '/logs/testing/ArchivePost.log');
        try {
            Log::info("=== Archive post queue run===");
            Log::info("dateTime=>" . date('Y-m-d h:m:s A'));
            Log::info($data);
            if ($job->attempts() <= 2 && !empty($data)){
                if(isset($data['post_id']) && !empty($data['post_id'])){
                    $response = PostArchiveProcess::getInstance()->deletePost($data['post_id']);
                    if($response->hasError()){
                        $job->delete();
                        Log::info("(26 Queue)Post Delete Error: ".$response->getError());
                    }else{
                        $job->delete();
                        Log::info("Post Delete Success: ".$response->getResponse());
                    }
                }else{
                    $job->delete();
                    Log::info("=== Post index not found ===");
                }
            }else{
                $job->delete();
                Log::info("=== Queue data not found ===");
            }

        } catch (Exception $ex) {
            $job->delete();
            Utility::store_exception($ex);
            Log::info("Post Delete Queue Exception: ".$ex->getMessage());
            Log::info("Post Data: ".$data);
        }
    }

0 个答案:

没有答案