2017 © Pedro Peláez
 

library queue-amq

Zend Framework 2 module that integrates with Active MQ queuing system

image

slm/queue-amq

Zend Framework 2 module that integrates with Active MQ queuing system

  • Sunday, May 31, 2015
  • by juriansluiman
  • Repository
  • 2 Watchers
  • 3 Stars
  • 3,356 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 4 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

SlmQueueAmq

Build Status PHP 7 ready Code Coverage Latest Stable Version Latest Unstable Version Scrutinizer Code Quality Dependency Status, (*1)

Created by Jurian Sluiman, (*2)

Requirements

Installation

First, install SlmQueue (instructions here). Then, add the following line into your composer.json file:, (*3)

"require": {
    "slm/queue-amq": "0.4.*"
}

Then, enable the module by adding SlmQueueAmq in your application.config.php file. You may also want to configure the module: just copy the slm_queue_amq.local.php.dist (you can find this file in the config folder of SlmQueueAmq) into your config/autoload folder, and override what you want., (*4)

Documentation

Before reading SlmQueueAmq documentation, please read SlmQueue documentation., (*5)

(Don't forget to first install Active MQ, and to run the daemon program on the server), (*6)

Setting the connection parameters

Copy the slm_queue_amq.local.php.dist file to your config/autoload folder, and follow the instructions., (*7)

Adding queues

A concrete class that implements the SlmQueue interface for Active MQ is included as SlmQueueAmq\Queue\AmqQueue and a factory is available to create the queue. Therefore, if you want to have a queue called "email", just add the following line in your module.config.php file:, (*8)

return array(
    'slm_queue' => array(
        'queue_manager' => array(
            'factories' => array(
                'email' => 'SlmQueueAmq\Factory\AmqQueueFactory'
            )
        )
    )
);

This queue can therefore be pulled from the QueuePluginManager class., (*9)

Operations on queues

push

Valid options are all constants on the SlmQueueAmq\Queue\AmqQueueInterface interface:, (*10)

  • AmqQueueInterface::DELAY: the delay in milliseconds before a job become available to be popped (defaults to no delay)
  • AmqQueueInterface::PERIOD: in milliseconds, how much time a job can be running for before it's put back into the queue
  • AmqQueueInterface::REPEAT: the number of times the job should be repeatedly available (defaults to 1, no repeating jobs)
  • AmqQueueInterface::CRON: a CRON string to schedule the job via cron
  • AmqQueueInterface::PERSIST: set to true to send a persistent message

Example:, (*11)

use SlmQueueAmq\Queue\AmqQueueInterface as Amq;

$queue->push($job, array(
    Amq::CRON     => '0 * * * *',
    Amq::DELAY    => 1000,
    Amq::PERIOD   => 1000,
    Amq::REPEAT   => 9
));

The above code will deliver the job 10 times, with a one second delay between each job, and this will happen every hour. See more explaination about the options in the Active MQ manual., (*12)

pop

Valid option is:, (*13)

  • timeout: by default, when we ask for a job, it will block until a job is found (possibly forever if new jobs never come). If you set a timeout (in seconds), it will return after the timeout is expired, even if no jobs were found

Executing jobs

SlmQueueAmq provides a command-line tool that can be used to pop and execute jobs. You can type the following command within the public folder of your Zend Framework 2 application:, (*14)

php index.php queue amq <queue> [--timeout=], (*15)

The queue is a mandatory parameter, while the timeout is an optional flag that specifies the duration in seconds for which the call will wait for a job to arrive in the queue before returning (because the script can wait forever if no job come)., (*16)

The Versions

31/05 2015
28/05 2015

dev-feature/stomp-pecl

dev-feature/stomp-pecl https://github.com/juriansluiman/SlmQueueAmq

Zend Framework 2 module that integrates with Active MQ queuing system

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 queue job stomp activemq amq active-mq