Download the PHP package heristop/jobqueue-bundle without Composer
On this page you can find all versions of the php package heristop/jobqueue-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jobqueue-bundle
JobQueueBundle
This bundle provides the use of Zend Queue
from Zend Framework. It allows your Symfony 2/3 application to schedule multiple console commands as server-side jobs.
See the Programmer's Reference Guide for more information.
Features:
- Manage multiple queues
- Schedule your Symfony commands
- Monitor messages and log exceptions
- Retry logic
- Prioritizing jobs
- RabbitMQ or database support
- Easy-to-use :)
Installation
Require heristop/jobqueue-bundle
to your composer.json
file:
Load the bundle in AppKernel:
If you use the Doctrine adapter, update your database:
If you use the Amqp adapter, you may configure the connection in this way:
Usage
First, define a message which contains the Symfony command to call. For instance, we choose to add the clear command in a queue named "queue1":
You can also call commands with arguments:
Then, add the queue to listen in the configuration:
Note: The queue is automatically created, but you can also use the command-line interface in this way:
Listener Commands
Run the Listener
To run new messages pushed into the queue, execute this command:
Specify a specific Queue
You may specify which queue connection the listener should utilize (skipping configuration):
Specify the Sleep Duration
You may also specify the number of seconds to wait before polling for new jobs:
Process the first Job on the Queue
To process only the first job on the queue, you may use the jobqueue:work
command:
Show Jobs
To see the pending jobs, run the command below:
Failed Jobs
If a job failed, the exception is logged in the database, and the command is call again after the setted timeout (default 90 seconds):
To delete all of your failed jobs, you may use the jobqueue:flush
command:
Jobs Priority
Jobs are executed in the order in which they are scheduled (assuming they are in the same queue). You may also prioritize a call:
Jobs Monitoring
If you use the Doctrine Adapter, you may use Sonata Admin to monitor your jobs:
Retry strategy
By default, number of excecution of failed messages is endless. If you use the Doctrine Adapter you may edit the max number of retries on queue table.
To retry all of your failed jobs, you may use this command:
If you would like to delete a failed job, you may use this command:
Configure a daemon
The jobqueue:listen
command should be runned with the prod environnement and the quiet option to hide output messages:
To avoid a memory leak caused by the monolog fingers crossed handler, you may configure the limit buffer size on config_prod.yml
:
Linux ProTip:
To run the command as a service, edit jobqueue-service
shell in Resources/bin
.
Set the correct PROJECT_ROOT_DIR
value, and copy this file to /etc/init.d
.
Then use update-rc.d:
To remove the service, use this command:
If the service stopped suddenly, you may use supervisord
to restart it automatically.
A sample config might look like this:
All versions of jobqueue-bundle with dependencies
symfony/framework-bundle Version ~2.7|~3.0
symfony/finder Version ~2.7|~3.0
symfony/console Version ~2.7|~3.0
zendframework/zend-queue Version 2.0.*@dev