一、什么是yii2-queue?
Yii2-queue是Yii2.0 PHP框架下一个消息队列拓展插件,支持基于DB, Redis, RabbitMQ, AMQP, Beanstalk 和 Gearman等。yii2-queue GitHub地址:https://github.com/yiisoft/yii2-queue
二、如何安装yii2-queue?
php composer.phar require --prefer-dist yiisoft/yii2-queue
三、在Linux创建systemd系统服务监听队列消息
1、新增yii-queue.service文件,相关命令:vi /etc/systemd/system/yii-queue.service;
2、
[Unit]
Description=Yii Queue Worker
After=network.target
# the following two lines only apply if your queue backend is mysql
# replace this with the service that powers your backend
After=mysql.service
Requires=mysql.service
[Service]
User=www-data
Group=www-data
ExecStart=/usr/bin/php /www/project/yii queue/listen --verbose
Restart=on-failure
[Install]
WantedBy=multi-user.target
3、重载systemd配置文件使其生效,相关命令:systemctl daemon-reload;