# kylin-think-queue **Repository Path**: kylin87/kylin-think-queue ## Basic Information - **Project Name**: kylin-think-queue - **Description**: think-queue自定义封装 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2022-01-24 - **Last Updated**: 2024-10-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 本项目是对think-queu的二次封装 ## 安装方法 * 选择自己的thinkphp版本 * 安装think-queue ```shell composer require topthink/think-queue ``` fastadmin项目自带的有think-queue,但是版本较低,可以升级到2.0 ```shell composer require topthink/think-queue:* ``` * 导入任务记录表(注意前缀) ```mysql CREATE TABLE `fa_queue_log` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `result` tinyint(1) NOT NULL DEFAULT '0' COMMENT '结果 0失败 1成功', `result_message` varchar(255) NOT NULL DEFAULT '' COMMENT '结果信息', `job_id` varchar(50) NOT NULL DEFAULT '' COMMENT '任务id', `attempts` int(5) NOT NULL DEFAULT '0' COMMENT '失败次数', `job` varchar(255) NOT NULL DEFAULT '1' COMMENT '操作任务', `param` text NOT NULL COMMENT '参数数据', `queue` varchar(255) NOT NULL DEFAULT '' COMMENT '队列名', `drive` varchar(255) NOT NULL DEFAULT '' COMMENT '驱动', `created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=614 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='队列日志表'; ``` * 复制对应目录的文件到项目,注意处理配置文件,已自动生成 ## 使用方法 * 执行任务消费命令 ```shell php think queue:listen --tries 1 ``` * 尝试插入一条任务,在代码中插入以下命令执行文件 ```shell Queues::now('hello'); ``` * 观察消费是否执行,queue_log数据库中是否新增了记录