2017 © Pedro Peláez
 

yii2-extension yii2-cmq

yii2 cmq扩展

image

xiaochengfu/yii2-cmq

yii2 cmq扩展

  • Thursday, January 4, 2018
  • by xiaochengfu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 80 % Grown

The README.md

yii2-cmq

对接腾讯cmq的消息队列, (*1)

配置

在common/config/params.php 添加如下参数:, (*2)

<?php
return [
    'cmq'=>[
       'secretId'=>'您的腾讯id',
       'secretKey'=>'您的key',
       'endpoint'=>'http://cmq-queue-bj.api.qcloud.com',//地区域名
       'queueName'=>'queue-v1',//队列名称
       'processName'=>'cmq-master',//进程名称
       'callback'=>'common\\components\\cmq\\Consumer'//消费业务回调处理名字空间
    ]
];

在console/config/ain.php中添加如下参数:, (*3)

  'controllerMap' => [
        'cmq-consumer'=>\xiaochengfu\cmq\controllers\ConsumerController::class,
        'cmq-producer'=>\xiaochengfu\cmq\controllers\ProducerController::class,
    ],

启动消费进程

./yii cmq-consumer/start

发布消息

Yii::$app->mq->poll(['1'=>'我收到了','2'=>'我成功了'])

删除消息

Yii::$app->mq->delete($receiptHandle)

回调处理参考配置

目录结构:common/components/cmq/Consumer.php, (*4)

注意:execute方法不可变更

Consumer.php内容如下:, (*5)

<?php
/**
 * Name: cmq回调处理类
 * Author: hp <xcf-hp@foxmail.com>
 * Date: 2017-11-22 18:17
 * Description: adf.php.
 */
namespace common\components\cmq;

use yii\base\Exception;

class Consumer
{

    /**
     * Description:  异步回调执行体
     * Author: hp <xcf-hp@foxmail.com>
     * Updater:
     * @return int
     */
    public function execute($msg)
    {
        try{
              $data = unserialize($msg['msgBody']);
              var_dump($msg);
        }catch (Exception $e){
            var_dump($e->getMessage());
        }

    }
}

The Versions

04/01 2018

dev-master

9999999-dev

yii2 cmq扩展

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 cmq yii2-cmq

02/01 2018

v1.0.1

1.0.1.0

yii2 cmq扩展

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 cmq yii2-cmq