slm/queue-amq 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

slm/queue-amq

最新稳定版本:v0.1.0

Composer 安装命令:

composer require slm/queue-amq

包简介

Zend Framework 2 module that integrates with Active MQ queuing system

README 文档

README

Build Status PHP 7 ready Code Coverage Latest Stable Version Latest Unstable Version Scrutinizer Code Quality Dependency Status

Created by Jurian Sluiman

Requirements

Installation

First, install SlmQueue (instructions here). Then, add the following line into your composer.json file:

"require": {
    "slm/queue-amq": "0.4.*"
}

Then, enable the module by adding SlmQueueAmq in your application.config.php file. You may also want to configure the module: just copy the slm_queue_amq.local.php.dist (you can find this file in the config folder of SlmQueueAmq) into your config/autoload folder, and override what you want.

Documentation

Before reading SlmQueueAmq documentation, please read SlmQueue documentation.

(Don't forget to first install Active MQ, and to run the daemon program on the server)

Setting the connection parameters

Copy the slm_queue_amq.local.php.dist file to your config/autoload folder, and follow the instructions.

Adding queues

A concrete class that implements the SlmQueue interface for Active MQ is included as SlmQueueAmq\Queue\AmqQueue and a factory is available to create the queue. Therefore, if you want to have a queue called "email", just add the following line in your module.config.php file:

return array(
    'slm_queue' => array(
        'queue_manager' => array(
            'factories' => array(
                'email' => 'SlmQueueAmq\Factory\AmqQueueFactory'
            )
        )
    )
);

This queue can therefore be pulled from the QueuePluginManager class.

Operations on queues

push

Valid options are all constants on the SlmQueueAmq\Queue\AmqQueueInterface interface:

  • AmqQueueInterface::DELAY: the delay in milliseconds before a job become available to be popped (defaults to no delay)
  • AmqQueueInterface::PERIOD: in milliseconds, how much time a job can be running for before it's put back into the queue
  • AmqQueueInterface::REPEAT: the number of times the job should be repeatedly available (defaults to 1, no repeating jobs)
  • AmqQueueInterface::CRON: a CRON string to schedule the job via cron
  • AmqQueueInterface::PERSIST: set to true to send a persistent message

Example:

use SlmQueueAmq\Queue\AmqQueueInterface as Amq;

$queue->push($job, array(
    Amq::CRON     => '0 * * * *',
    Amq::DELAY    => 1000,
    Amq::PERIOD   => 1000,
    Amq::REPEAT   => 9
));

The above code will deliver the job 10 times, with a one second delay between each job, and this will happen every hour. See more explaination about the options in the Active MQ manual.

pop

Valid option is:

  • timeout: by default, when we ask for a job, it will block until a job is found (possibly forever if new jobs never come). If you set a timeout (in seconds), it will return after the timeout is expired, even if no jobs were found

Executing jobs

SlmQueueAmq provides a command-line tool that can be used to pop and execute jobs. You can type the following command within the public folder of your Zend Framework 2 application:

php index.php queue amq <queue> [--timeout=]

The queue is a mandatory parameter, while the timeout is an optional flag that specifies the duration in seconds for which the call will wait for a job to arrive in the queue before returning (because the script can wait forever if no job come).

slm/queue-amq 适用场景与选型建议

slm/queue-amq 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.37k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「zf2」 「stomp」 「activeMQ」 「job」 「amq」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 slm/queue-amq 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 slm/queue-amq 我们能提供哪些服务?
定制开发 / 二次开发

基于 slm/queue-amq 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-04-28