定制 fordnox/php-queue-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fordnox/php-queue-manager

最新稳定版本:0.3

Composer 安装命令:

composer require fordnox/php-queue-manager

包简介

PHP Queue with database backend. Use sqlite, mysql, postgres database

README 文档

README

Build Status

Queue manager - A simple, fast queue manager and tasks executor. Stack your tasks to queue and execute them later.

PHP Queue Manager is a very light component designed to be simple, fast and secure queue manager and executor for PHP. It is a way to manage asynchronous, potentially long-running PHP tasks such as API requests, database export/import operations, email sending, payment notification handlers, feed generation etc.

Queue manager can be integrated to any PHP based application with minimum effort, because it does not depend on any framework. PDO extension is the only requirement. PHP Queue manager is for those who wants to have a queue running in less than a minute. No additional installation is required.

You can have more than one queue manager running on a single application. Manager instances will always select unique messages from queue. Messages that fail to execute (throws Exception) will stay in queue. Exception message can be viewed in queue manager. Executor will try to execute failed message once again after timeout is reached.

Component does not handle dependencies with other messages. That means that message in a queue knows nothing about other messages in queue. For those who searches for solution to this problem - Gearman is the way to go, but requires time for setup.

Requirements

  • PHP >5.3
  • PDO
  • Database backend (sqlite, sqlite memory, mysql, postgres, any PDO supported database)

Install with Composer

  • Install dependency
{
    "require": {
        "fordnox/php-queue-manager": "0.3"
    }
}
  • Use included sqlite file (extra/queue.sqlite) for basic backend system to connect to via PDO
$dbh = new PDO('sqlite:queue.sqlite');
$dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION );
$dbh->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
$dbh->exec($structure);

Example Queue

$message = new \QueueExample\Dummy();

$manager = new \Queue\Manager();
$manager->setPdo($dbh);
$manager->addMessageToQueue($message, 'AmazonEmailsQueue');

// Usually this call should be executed via cron or some other worker
$amazonEmails = $manager->getQueue('AmazonEmailsQueue');
$amazonEmails->execute();

Todo

  • Write tests for all SQL backends
  • Create simple Web Interface

统计信息

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

GitHub 信息

  • Stars: 54
  • Watchers: 9
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-17