php消息队列之 think queue消息队列初体验

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php消息队列之 think queue消息队列初体验相关的知识,希望对你有一定的参考价值。

  使用thinkphp 5的  消息队列 think queue 

● php think queue:listen --queue queuename
● php think queue:work --daemon --queue xwyqueue

使用这两个命令进行消息队列的监控,在整个Linux操作界面关闭以后,发现就无法运行了。

原因就是这个进程没有常驻在系统后台。那么就需要用到liunx操作系统的 supervisor 来保证进程常驻

在百度搜索 supervisor 的安装 使用  

然后配置好 supervisor.conf文件

 

[program:php]
command= /usr/bin/php think queue:work --queue xwyqueue --daemon ; 被监控进程
directory=/www/website/weixin/
;process_name=%(process_num)02d
;numprocs=5 #启动几个进程
autostart=true ;随着supervisord的启动而启动
autorestart=true ;自动启动
startsecs=1 ;程序重启时候停留在runing状态的秒数
startretries=10 ;启动失败时的最多重试次数
redirect_stderr=true ;重定向stderr到stdout
stdout_logfile=/root/supervisor.log ;stdout文件


配置好以后

启动Supervisor服务
supervisord -c /etc/supervisor/supervisord.conf

在执行命令出现以下提示信息时:
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
For help, use /usr/bin/supervisord –h
是因为有一个使用supervisor配置的应用程序正在运行,需要执行supervisorctl shutdown命令终止

supervisorctl status #查看所有任务状态

 

 

 

我,秋峰,phper,目前创业,做项目系统开发   相互学习  共同提高   微信号:qiufeng2983  

 




















以上是关于php消息队列之 think queue消息队列初体验的主要内容,如果未能解决你的问题,请参考以下文章

ThinkPHP think-queue 消息队列

thinkphp5 消息队列thinkphp-queue扩展

Java开发 - 消息队列之RabbitMQ初体验

[PHP] 多进程通信-消息队列使用

thinkPhp使用框架自带队列think-queue

如何用php获取rabbitmq指定队列中的未处理消息数量