Php-Redis 邮件队列实现总结
来源:互联网 发布:全球通用聊天软件 编辑:程序博客网 时间:2024/05/21 23:20
1. php- redis 实现的队列相关文章
https://github.com/vincenthou/vincenthou.github.io/issues/17
https://github.com/chrisboulton/php-resque/issues/32
http://www.cnblogs.com/zl0372/p/PHP-Resque2.html
http://blog.hsatac.net/2012/01/php-resque-introduction/
http://www.cnblogs.com/zl0372/p/3696641.html
http://www.yiiframework.com/extension/yii-resque/
http://git.oschina.net/VincentHou/yii-resque-ex#git-readme
2.安装ruby监控程序,监控处理队列任务的workers
- 安装
gem install resque - 运行
resque-web -p 3000
resque-web -p 3001 -r redis://user:Raiing2015@127.0.0.1:6379 -d
- 访问
访问:127.0.0.1:3000
3.使用redis-cli连接redis
redis-cli -h 127.0.0.1 -p 6379
都为默认值可以省略 auth redis-pass
验证有密码的redis server
redis 带密码的停止服务
redis-cli -p 6379 -a 654321 shutdown
4.单独设置worker启动
- 启动
./yiic rresque start --queue=email,sms[*] --interval=2 --verbose=0 --count=2
- interval 的意思是如果当前队列里面没有内容,会睡眠多长时间
- 停止所有
./yiic rresque stop
5.启动管理worker进程的进程supervisord
- 启动
supervisord -c /etc/supervisor/supervisord.conf
- 停止
supervisorctl -uadmin -padmin
reload
重新加载supervisord的配置文件【/etc/supervisor/supervisord.conf】
- 将worker进程添加到supervisord,使用supervisord管理
- 该方案不行, supervisord只能监控后台守护程序
6.redis中的队列信息存储
1. 失败job的记录
获取失败的job数量
字符串类型
get resque:stat:failed
获取job错误的详细信息
list类型
LRANGE resque:failed 0 -1
2. worker相关信息 hash类型
- 获取worker日志存储的位置
HGETALL workerLogger
- 获取某一个worker的处理任务数量
字符串类型
get resque:stat:processed:evolution-ThundeRobot:20677:sms[jobname]
- 获取某个worker的启动时间
字符串类型
get resque:worker:evolution-ThundeRobot:13598:sms:started
3. 任务相关
- 任务列表
list类型
- 获取长度:
LLEN resque:queue:email[jobname]
- 查看所有的详细内容
LRANGE resque:queue:email[jobname] 0 -1
- 获取长度:
- 获取每个任务的状态信息
get resque:job:1e46c7a14b15700f271c5cec53d26511:status
字符串类型
4. 队列类型相关信息【email sms other……】 Set集合类型
- 获取当前队列类型的个数
SCARD resque:queues
- 获取当前都有那些类型的队列
SMEMBERS resque:queues
7.Yii配置有关
1. console.php
//base 'sourceLanguage'=>'en_us,zh_cn', 'language'=>'zh_cn',//components 'resque'=>array( 'class' => 'application.components.yii-resque.RResque', 'server' => 'localhost', // Redis server address 'port' => '6379', // Redis server port 'database' => 0, // Redis database number 'password' => '', // Redis password auth, set to '' or null when no auth needed 'includeFiles' => array(), // Absolute path of files that will be included when initiate queue 'loghandler' => 'RotatingFile', // Monolog handler type without "handler" 'logtarget' => '/var/log/mylog', // Target log file or configuration (please refer to logging section) ),
2. 邮件配置
<?phpreturn array( 'viewPath' => 'application.views.mail', 'layoutPath' => 'application.views.layouts', 'baseDirPath' => 'webroot.images.mail', //note: 'webroot' alias in console apps may not be the same as in web apps 'savePath' => 'webroot.assets.mail', 'testMode' => false, 'layout' => 'mail', 'CharSet' => 'UTF-8', 'AltBody' => Yii::t('YiiMailer', 'You need an HTML capable viewer to read this message.'), 'language' => array( 'authenticate' => Yii::t('YiiMailer', 'SMTP Error: Could not authenticate.'), 'connect_host' => Yii::t('YiiMailer', 'SMTP Error: Could not connect to SMTP host.'), 'data_not_accepted' => Yii::t('YiiMailer', 'SMTP Error: Data not accepted.'), 'empty_message' => Yii::t('YiiMailer', 'Message body empty'), 'encoding' => Yii::t('YiiMailer', 'Unknown encoding: '), 'execute' => Yii::t('YiiMailer', 'Could not execute: '), 'file_access' => Yii::t('YiiMailer', 'Could not access file: '), 'file_open' => Yii::t('YiiMailer', 'File Error: Could not open file: '), 'from_failed' => Yii::t('YiiMailer', 'The following From address failed: '), 'instantiate' => Yii::t('YiiMailer', 'Could not instantiate mail function.'), 'invalid_address' => Yii::t('YiiMailer', 'Invalid address'), 'mailer_not_supported' => Yii::t('YiiMailer', ' mailer is not supported.'), 'provide_address' => Yii::t('YiiMailer', 'You must provide at least one recipient email address.'), 'recipients_failed' => Yii::t('YiiMailer', 'SMTP Error: The following recipients failed: '), 'signing' => Yii::t('YiiMailer', 'Signing Error: '), 'smtp_connect_failed' => Yii::t('YiiMailer', 'SMTP Connect() failed.'), 'smtp_error' => Yii::t('YiiMailer', 'SMTP server error: '), 'variable_set' => Yii::t('YiiMailer', 'Cannot set or reset variable: ') ),// if you want to use SMTP, uncomment and configure lines below to your needs 'Mailer' => 'smtp', 'Host' => 'smtp.office365.com', 'Port' => 587, 'SMTPSecure' => 'tls', 'SMTPAuth' => true, 'Username' => 'tjww@raiing.onmicrosoft.com', 'Password' => 'LByzHC=:N2',);
3.mail->smtp设置
public function setSmtp($host='localhost',$port=25, $secure='', $auth=false, $username='', $password='') { $this->isSMTP(); $this->Host = $host; $this->Port = $port; $this->SMTPSecure = $secure; $this->SMTPAuth = $auth; $this->Username = $username; $this->Password = $password; $this->CharSet = "UTF-8"; //字符集 $this->Encoding = "base64"; //编码方式 $this->isHTML(true); }
1 0
- Php-Redis 邮件队列实现总结
- php+redis实现消息队列
- 使用Redis+php-resque实现消息队列
- PHP用redis实现多进程队列
- Redis PHP Set集合实现消息队列
- Redis PHP Set集合实现消息队列
- php+redis消息队列抢购实现
- php-redis队列实现抢购商品
- php 实现 redis 队列,等待有新消息入列
- 基于redis+mysql+php的简单队列实现
- php实现redis消息队列将数据保存到mysql
- Redis实现消息队列
- redis实现有序队列
- redis实现消息队列
- redis实现消息队列
- redis实现消息队列
- redis队列的实现
- redis队列的实现
- 线程的堆区和栈区
- Angular2教程(一)
- IDEA maven 下载 源码和javadoc命令
- java 中的数学计算函数
- MySQL的运算符
- Php-Redis 邮件队列实现总结
- GB2312和ASCII码点阵字库HZK, ASC说明使用心得,全
- Python正则表达式指南
- sigsegv 問題的調是
- in-memory形式的牧户K-Means聚类
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 【leetcode】【14】Longest Common Prefix
- 如何用javascript实现 网页标题的滚动效果