springbot/magento2-queue
Composer 安装命令:
composer require springbot/magento2-queue
包简介
A generic job queuing package for Magento 2
README 文档
README
Magento2 Job Queue
This module provides functionality to schedule and run jobs in a queue for Magento2. The basic idea is to allow developers to defer tasks that would otherwise delay the page load time and cause site slowness. Example use cases may be sending an email, communicating with a remote API, or running cleanup tasks in the background.
While originally written for our Springbot Magento2 integration, this module can be utilized for many other use cases.
The module provides both programmatic and command line ways to enqueue, run, and view jobs. The key components of a job are a fully qualified class name, a method name, and a list of arguments. There are a few requirements: the class must be autoloadable, the method must be public, and the params must not contain objects. Additional options are priority, queue name, and "run at" time.
Installation
Composer is the preferred method of installation:
composer require springbot/magento2-queue php bin/magento module:enable Springbot_Queue
Command line usage
Enqueue a job
php bin/magento springbot:queue:enqueue <class> <method> [<queue>] [<priority>] [<params>1] ... [<params>N]
List current jobs in the queue
php bin/magento springbot:queue:list
Process the queue
php bin/magento springbot:queue:process
Programmatic usage
<?php namespace Your\Name\Space; use Springbot\Queue\Model\Queue; class QueueExample { private $queue; /** * QueueExample constructor * @param Queue $queue */ public function __construct(Queue $queue) { $this->queue = $queue; } /** * Queue examples */ public function runQueueExamples() { // Enqueue a job $this->queue->scheduleJob('\Fully\Qualified\ClassName', 'methodToRun', ['arg1', 'arg2']); // Process the queue $this->queue->runNextJob(); // Get a collection of current jobs $jobs = $this->queue->getCollection(); } }
API Usage
To process the queue make a GET request to the following API endpoint:
/V1/springbot/queue/process
To view current jobs make a GET request to the following API endpoint:
/V1/springbot/queue/jobs
For security purposes jobs cannot be enqueued directly from the web API.
springbot/magento2-queue 适用场景与选型建议
springbot/magento2-queue 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62.75k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2016 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 springbot/magento2-queue 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 springbot/magento2-queue 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 62.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 15
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: OSL-3.0
- 更新时间: 2016-03-13