jkowens/magento-jobqueue
Composer 安装命令:
composer require jkowens/magento-jobqueue
包简介
JobQueue for Magento using DJJob
README 文档
README
JobQueue allows Magento applications to place tasks in a queue to be processed asynchronously. It is built on DJJob and makes use of the existing MySQL backend. Some tasks this may be ideal for are:
- Downloading files
- Processing batch jobs
- Sending data to a back-office application or third party systems
System Requirements
- PHP 5.1 or higher
- MySQL 4.1.20 or higher
- Magento CE1.6.0-1.9.x/EE1.7.0-1.14.x
Usage
Jobs must extend Jowens_JobQueue_Model_Job_Abstract and implement the perform() method.
class Foo_Bar_Model_Order_Job extends Jowens_JobQueue_Model_Job_Abstract
{
public function perform() {
// implementation logic
}
}
That job can then be used like so:
$job = Mage::getModel('bar/order_job');
$job->setName('Order# 12345')
->enqueue();
Name is used to identify the job in backend, so be descriptive! The enqueue method can take two optional parameters, a string for queue name and timestamp to specify a time to run the job.
The job can also be attempted immediately. If it fails it is added to the default queue for retry.
$job = Mage::getModel('bar/order_job');
$job->setName('Order# 12345')
->performImmediate();
To put the job on a queue other than the default one, performImmediate takes an optional string value for the name of the retry queue.
Running Jobs
JobQueue requires Magento cron to be configured in order to run pending jobs. By default a JobQueue worker executes the pending jobs every 5 minutes. If a job fails it will be retried up to 10 times. Both of these settings can be configured in the admin panel under System > Configuration > General > JobQueue.
Jobs in other queues can be executed by adding more cron entries to a custom module config.xml.
<crontab>
<jobs>
<jobqueue_orders>
<schedule>
<config_path>jobqueue/config/cron_expr</config_path>
</schedule>
<run>
<model>jobqueue/worker::executeJobs</model>
</run>
<queue>orders</queue>
</jobqueue_orders>
</jobs>
</crontab>
Alternatively workers could be configured to run as they normally would using DJJob. See the documentation.
Monitoring Jobs
Pending and failed jobs can be monitored in the admin panel by going to System > JobQueue.
jkowens/magento-jobqueue 适用场景与选型建议
jkowens/magento-jobqueue 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 48.25k 次下载、GitHub Stars 达 52, 最近一次更新时间为 2016 年 08 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jkowens/magento-jobqueue 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jkowens/magento-jobqueue 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 48.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 52
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-02