2017 © Pedro Peláez
 

magento2-module magento2-queue

A generic job queuing package for Magento 2

image

springbot/magento2-queue

A generic job queuing package for Magento 2

  • Wednesday, January 31, 2018
  • by springbot
  • Repository
  • 26 Watchers
  • 5 Stars
  • 8,438 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 5 Forks
  • 5 Open issues
  • 13 Versions
  • 34 % Grown

The README.md

GPL licensed, (*1)

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., (*2)

While originally written for our Springbot Magento2 integration, this module can be utilized for many other use cases., (*3)

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., (*4)

Installation

Composer is the preferred method of installation:, (*5)

composer require springbot/magento2-queue
php bin/magento module:enable Springbot_Queue

Command line usage

Enqueue a job, (*6)

 php bin/magento springbot:queue:enqueue <class> <method> [<queue>] [<priority>] [<params>1] ... [<params>N]

List current jobs in the queue, (*7)

 php bin/magento springbot:queue:list

Process the queue, (*8)

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:, (*9)

/V1/springbot/queue/process

To view current jobs make a GET request to the following API endpoint:, (*10)

/V1/springbot/queue/jobs

For security purposes jobs cannot be enqueued directly from the web API., (*11)

The Versions

31/01 2018

dev-master

9999999-dev

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

31/01 2018

1.1.11

1.1.11.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

28/12 2017

1.1.10

1.1.10.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

15/05 2017

1.1.9

1.1.9.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

13/04 2017

1.1.8

1.1.8.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

27/09 2016

1.1.6

1.1.6.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

01/06 2016

1.1.4

1.1.4.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

20/05 2016

1.1.3

1.1.3.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

20/05 2016

1.1.2

1.1.2.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

14/03 2016

1.0.3

1.0.3.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

13/03 2016

1.0.2

1.0.2.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

13/03 2016

1.0.1

1.0.1.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0

13/03 2016

1.0.0

1.0.0.0

A generic job queuing package for Magento 2

  Sources   Download

OSL-3.0