2017 © Pedro Peláez
 

yii2-extension yii2-mq

The message queue extension for the Yii framework

image

xutl/yii2-mq

The message queue extension for the Yii framework

  • Saturday, March 10, 2018
  • by xutl
  • Repository
  • 0 Watchers
  • 11 Stars
  • 109 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

yii2-mq

适用于Yii2的消息服务组件,支持阿里云的MNS,AWS的SQS,以及Redis。, (*1)

Latest Stable Version Total Downloads Reference Status Build Status Dependency Status License, (*2)

特别说明:非任务队列,也不是短消息那种私信组件,这是个纯消息组件。本来我是想做队列,我看了laravel,以及yii2其他人做的队列任务组件,我发现, 他们下发任务的时候要么发个闭包,要么发个序列化的类,包括我之前做的一个队列组件也是这么做的,后来我看了阿里云的消息队列服务的开发者 文档我觉得,消息服务本质上就是个纯消息服务,没必要把任务也放里面,一条消息就是一个普通的JSON字符串就行了,就像微信的公众号接收 服务端消息一样,接到消息干什么,怎么干我觉得是客户端的事。, (*3)

队列说明

之前看yiisoft上那个队列半成品给我带到沟里了,且它自带的redis的一直有bug,常年不维护。, (*4)

下面是队列说明:, (*5)

1、插入队列的消息,可以是数组或者是json,不要直接把任务对象放入队列。 2、消费消息时,该消息只是进入了保留期,大概1分钟后又会重新进入队列。 3、如果你消费消息后,处理该消息失败,或者其他原因需要修改保留期有相应的方法修改。 4、在消息消费完,你需要手动删除该消息。, (*6)

以上概念是按照 阿里云的 https://help.aliyun.com/document_detail/27414.html 实现的, (*7)

知乎上这篇甩锅我给我很大的启发。 https://zhuanlan.zhihu.com/p/25192112, (*8)

安装

The preferred way to install this extension is through composer., (*9)

Either run, (*10)

php composer.phar require --prefer-dist xutl/yii2-mq

or add, (*11)

"xutl/yii2-mq": "~1.0.0"

to the require section of your composer.json file., (*12)

组件配置

//使用Redis
'queue' => [
    'class' => 'xutl\mq\redis\Client',
                'redis' => [
                    'scheme' => 'tcp',
                    'host' => '127.0.0.1',
                    'port' => 6379,
                    //'password' => '1984111a',
                    'db' => 0
                ],
],

//使用AWS SQS
'queue' => [
    'class' => 'xutl\mq\awsqs\Client',
                'sqs' => [
                    //etc
                ],
],
//使用阿里MNS
'queue' => [
   'class' => 'xutl\mq\alimns\Client',
               'endPoint' => '',
               'accessId'=>'',
               'accessKey'=>'',
],        

使用


//入队 /** @var \xutl\mq\Queue $queue */ $queue = Yii::$app->queue->getQueueRef('mailer'); for ($i = 0; $i < 500; $i++) { $queue->sendMessage([ 'aaa'=>'bbb', ]); } //出队 /** @var \xutl\mq\Queue $queue */ $queue = Yii::$app->queue->getQueueRef('mailer'); /** @var \xutl\mq\Message $message */ while (($message = $queue->receiveMessage()) !== false) { $body = $message->getBody(); var_dump($body); $message->delete(); }

License

This is released under the MIT License. See the bundled LICENSE.md for details., (*13)

The Versions

10/03 2018

dev-master

9999999-dev

The message queue extension for the Yii framework

  Sources   Download

MIT BSD-3-Clause

The Requires

 

The Development Requires

by X TL

yii2 queue message aliyun

10/03 2018

1.0.9

1.0.9.0

The message queue extension for the Yii framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by X TL

yii2 queue message aliyun

14/08 2017

1.0.8

1.0.8.0

The message queue extension for the Yii framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by X TL

yii2 queue message aliyun

14/08 2017

1.0.7

1.0.7.0

The message queue extension for the Yii framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by X TL

yii2 queue message aliyun

07/08 2017

1.0.6

1.0.6.0

The message queue extension for the Yii framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by X TL

yii2 queue message aliyun

08/04 2017

1.0.5

1.0.5.0

The message queue extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by X TL

yii2 queue message

28/03 2017

1.0.4

1.0.4.0

The message queue extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by X TL

yii2 queue message

28/03 2017

1.0.3

1.0.3.0

The message queue extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by X TL

yii2 queue message

28/03 2017

1.0.2

1.0.2.0

The message queue extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by X TL

yii2 queue message

09/03 2017

1.0.1

1.0.1.0

The message queue extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by X TL

yii2 queue message

21/02 2017

1.0.0

1.0.0.0

The message queue extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by X TL

yii2 queue message