Download the PHP package mcfedr/queue-manager-bundle without Composer

On this page you can find all versions of the php package mcfedr/queue-manager-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package queue-manager-bundle

Queue Manager Bundle

A bundle for running background jobs in Symfony.

Latest Stable Version License Build Status

This bundle provides a consistent queue interface, with plugable 'drivers' that can schedule jobs using a number of different queue types:

There are also a number of 'helper' plugins:

Overview

A job is a Symfony service that implements the Worker interface. This has a single method execute(array $arguments). The name of the job is the service name.

You add jobs to the queue by calling $container->get(QueueManagerRegistry::class)->put($name, $arguments).

Check the documentation of the driver you are using as to how to run the daemon process(es).

Install

Composer

AppKernel

Include the bundle in your AppKernel

Config

You must configure one (or more) drivers to use. Generally you will have just one and call it 'default'.

Beanstalk

Usage

The beanstalk runner is a Symfony command. You can runner multiple instances if you need to handle higher numbers of jobs.

Where {name} is what you used in the config. Add -v or more to get detailed logs.

Config

Supported options to QueueManager::put

AWS SQS

Usage

The sqs runner is a Symfony command. You can runner multiple instances if you need to handle higher numbers of jobs.

Where {name} is what you used in the config. Add -v or more to get detailed logs.

Config

Supported options to QueueManager::put

GCP Pub/Sub

Usage

The pub/sub runner is a Symfony command. You can runner multiple instances if you need to handle higher numbers of jobs.

Where {name} is what you used in the config. Add -v or more to get detailed logs.

Config

Supported options to QueueManager::put

Periodic

This driver doesn't run jobs, it requires another driver to actually process jobs.

Usage

There is no runner daemon for this driver as it just plugs into other drivers. Use it by putting jobs into this driver with the period option.

Config

This will create a QueueManager service named "mcfedr_queue_manager.periodic".

Supported options to QueueManager::put

Doctrine Delay

This driver doesn't run jobs, it requires another driver to actually process jobs.

It currently only works with MySQL as a native query is required to find jobs in a concurrency safe way.

Usage

You should run the daemon for delay in addition to any other daemons you are using. This runner simply moves jobs from Doctrine into your other job queues. Because its not doing much work generally a single instance can cope with a high number of jobs.

Where {name} is what you used in the config. Add -v or more to get detailed logs.

Config

This will create a QueueManager service named "mcfedr_queue_manager.delay".

Supported options to QueueManager::put

Note

If delay or time option is less then 30 seconds the job will be scheduled for immediate execution unless the force_delay option is set to true

Tables

After you have installed you will need to do a schema update so that the table of delayed tasks is created.

Additional options

These are the defaults for a number of other options.

Option Means
retry_limit The number of times a job will be retried when it fails, unless it throws UnrecoverableJobExceptionInterface
sleep_seconds When a queue doesnt have any jobs it will wait this long before checking again
report_memory Enable a listener that reports current memory usage between each job, useful for debugging leaks
doctrine_reset This listener will reset doctrine connect between jobs. Be careful with your memory usage if disabled.

Doctrine

To avoid memory leaks entity manager is being reset after job execution.

Resetting a non-lazy manager service is deprecated since Symfony 3.2 and will throw an exception in version 4.0. So if you use Symfony 3.2 or greater you need to install symfony/proxy-manager-bridge to support Lazy Services.

Usage

You can access the QueueManagerRegistry for simple access to your queue. Just inject QueueManagerRegistry::class and call put to add new jobs to the queue.

Also, each manager will be a service you can access with the name "mcfedr_queue_manager.$name". It implements the QueueManager interface, where you can call just 2 simple methods.

/**
 * Put a new job on a queue
 *
 * @param string $name The service name of the worker that implements {@link \Mcfedr\QueueManagerBundle\Queue\Worker}
 * @param array $arguments Arguments to pass to execute - must be json serializable
 * @param array $options Options for creating the job - these depend on the driver used
 */
public function put(string $name, array $arguments = [], array $options = []): Job

/**
 * Remove a job, you should call this to cancel a job
 *
 * @param $job
 * @throws WrongJobException
 * @throws NoSuchJobException
 */
public function delete(Job $job): void;

Jobs

Jobs to run are Symfony services that implement Mcfedr\QueueManagerBundle\Queue\Worker There is one method, that is called with the arguments you passed to QueueManager::put.

/**
 * Called to start the queued task
 *
 * @param array $arguments
 * @throws \Exception
 */
public function execute(array $arguments): void;

If your job throws an exception it will be retried (assuming the driver supports retrying), unless the exception thrown is an instance of UnrecoverableJobExceptionInterface.

Workers should be tagged with mcfedr_queue_manager.worker, if you are using autowiring this will happen automatically.

By default the job name is the class, but you can also add tags with specific ids, e.g.

Now you can schedule this job with both:

Events

A number of events are triggered during the running of jobs.

Name Event Object
mcfedr_queue_manager.job_start StartJobEvent
mcfedr_queue_manager.job_finished FinishedJobEvent
mcfedr_queue_manager.job_failed FailedJobEvent
mcfedr_queue_manager.job_batch_start StartJobBatchEvent
mcfedr_queue_manager.job_batch_finished FinishedJobBatchEvent

Creating your own driver

Firstly a driver needs to implement a QueueManager. This should put tasks into queues.

The options argument can be used to accept any extra parameters specific to your implementation. For example, this might include a delay or a priority if you support that.

You also need to create a Job class, many drivers can just extend AbstractJob but you can add any extra data you need.

Creating a runner

Many drivers can use the RunnerCommand as a base, implementing the getJob method.

Other queue servers have their own runners, in which case you need to write the code such that the correct worker is called. The service mcfedr_queue_manager.job_executor can help with this.


All versions of queue-manager-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
symfony/framework-bundle Version ^5.0|^6.0|^7.0
nesbot/carbon Version ^1|^2|^3
ramsey/uuid Version ^3.7|^4.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mcfedr/queue-manager-bundle contains the following files

Loading the files please wait ....