定制 springbot/magento2-queue 二次开发

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

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

springbot/magento2-queue

最新稳定版本:1.2.2

Composer 安装命令:

composer require springbot/magento2-queue

包简介

A generic job queuing package for Magento 2

README 文档

README

GPL licensed

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.

统计信息

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

GitHub 信息

  • Stars: 17
  • Watchers: 28
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2016-03-13