PHPackages                             mcfedr/queue-manager-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. mcfedr/queue-manager-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

mcfedr/queue-manager-bundle
===========================

A bundle for managing job queues

7.3.0(1y ago)1094.4k10[6 PRs](https://github.com/mcfedr/queue-manager-bundle/pulls)7MITPHPPHP &gt;=8.0

Since Mar 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mcfedr/queue-manager-bundle)[ Packagist](https://packagist.org/packages/mcfedr/queue-manager-bundle)[ RSS](/packages/mcfedr-queue-manager-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (20)Versions (85)Used By (7)

Queue Manager Bundle
====================

[](#queue-manager-bundle)

A bundle for running background jobs in [Symfony](symfony.com).

[![Latest Stable Version](https://camo.githubusercontent.com/21ef70e33cb2334aa507b6ae8809c91c1a4d9006dd06d71b16d586dd5371e90d/68747470733a2f2f706f7365722e707567782e6f72672f6d63666564722f71756575652d6d616e616765722d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/mcfedr/queue-manager-bundle)[![License](https://camo.githubusercontent.com/785caa69f37c5eb7469437b0838befe511ade131dc9f79b2852f337c04de13e1/68747470733a2f2f706f7365722e707567782e6f72672f6d63666564722f71756575652d6d616e616765722d62756e646c652f6c6963656e73652e706e67)](https://packagist.org/packages/mcfedr/queue-manager-bundle)[![Build Status](https://camo.githubusercontent.com/0bcf016f3477338b11048740b6a2cb750b9dafe91460dc69e4e425a1b87086c2/68747470733a2f2f7472617669732d63692e6f72672f6d63666564722f71756575652d6d616e616765722d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mcfedr/queue-manager-bundle)

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

- [Beanstalkd](https://beanstalkd.github.io/)
- [Amazon SQS](https://aws.amazon.com/sqs/)
- [Google Cloud Pub/Sub](https://cloud.google.com/pubsub)

There are also a number of 'helper' plugins:

- [Doctrine Delay Queue](https://www.doctrine-project.org/)

    This plugins can schedule jobs far in advance and move them into a real time queue when they should be run. Use in combination with SQS or Beanstalkd which don't support scheduling jobs.
- Perioidic Jobs

    Automatically schedule a jobs to run every hour/day/week or other period. Randomizes the actual time to keep an even server load.

Overview
--------

[](#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
-------

[](#install)

### Composer

[](#composer)

```
composer require mcfedr/queue-manager-bundle
```

### AppKernel

[](#appkernel)

Include the bundle in your AppKernel

```
    public function registerBundles()
    {
        $bundles = [
            ...
            new Mcfedr\QueueManagerBundle\McfedrQueueManagerBundle(),
```

Config
------

[](#config)

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

### Beanstalk

[](#beanstalk)

#### Usage

[](#usage)

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

```
./bin/console mcfedr:queue:{name}-runner
```

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

#### Config

[](#config-1)

```
mcfedr_queue_manager:
    managers:
        default:
            driver: beanstalkd
            options:
                host: 127.0.0.1
                port: 11300
                default_queue: mcfedr_queue
```

#### Supported options to `QueueManager::put`

[](#supported-options-to-queuemanagerput)

- `queue` - The name of the queue to put the job in.
- `priority` - The job priority.
- `ttr` - Time to run, the time given for a job to finish before it is repeated.
- `time` - A `\DateTime` object of when to schedule this job.
- `delay` - Number of seconds from now to schedule this job.

### AWS SQS

[](#aws-sqs)

#### Usage

[](#usage-1)

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

```
./bin/console mcfedr:queue:{name}-runner
```

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

#### Config

[](#config-2)

```
mcfedr_queue_manager:
    managers:
        default:
            driver: sqs
            options:
                default_url: https://sqs.eu-west-1.amazonaws.com/...
                region: eu-west-1
                credentials:
                    key: 'my-access-key-id'
                    secret: 'my-secret-access-key'
                queues:
                    name: https://sqs.eu-west-1.amazonaws.com/...
                    name2: https://sqs.eu-west-1.amazonaws.com/...
```

- `default_url` - Default SQS queue url.
- `region` - The region where your queue is. Required if not passing `sqs_client`.
- `credentials` *optional* - [Specify your key and secret](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html#using-hard-coded-credentials)This is optional because the SDK can pick up your credentials from a [variety of places](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html).
- `sqs_client` - Name of `SQSClient` service to use.
- `queues` *optional* - Allows you to setup a mapping of short names for queues, this makes it easier to use multiple queues and keep the config in one place.

#### Supported options to `QueueManager::put`

[](#supported-options-to-queuemanagerput-1)

- `url` - A `string` with the url of a queue.
- `queue` - A `string` with the name of a queue in the config.
- `time` - A `\DateTime` object of when to schedule this job. **Note:** SQS can delay jobs up to 15 minutes.
- `delay` - Number of seconds from now to schedule this job. **Note:** SQS can delay jobs up to 15 minutes.
- `ttr` - Number of seconds during which Amazon SQS prevents other consumers from receiving and processing the message (SQS Visibility Timeout).

### GCP Pub/Sub

[](#gcp-pubsub)

#### Usage

[](#usage-2)

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

```
./bin/console mcfedr:queue:{name}-runner
```

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

#### Config

[](#config-3)

```
mcfedr_queue_manager:
    managers:
        default:
            driver: pub_sub
            options:
                default_subscription: 'test_sub'
                default_topic: 'projects/project/topics/test-topic'
                pub_sub_queues:
                    name1:
                        topic: 'projects/project/topics/test-topic'
                        subscription: 'test_sub'
```

- `default_subscription` - Default Pub/Sub subscription to listen to.
- `default_topic` - Default Pub/Sub topic to push to.
- `key_file_path` *optional* - Specify your key file. This is optional because the SDK can pick up your credentials from a [variety of places](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.107.1/guides/authentication).
- `pub_sub_client` - Name of `PubSubClient` service to use.
- `pub_sub_queues` *optional* - Allows you to setup a mapping of short names for queues, this makes it easier to use multiple queues and keep the config in one place. Each queue should have a `topic` and `subscription`.

#### Supported options to `QueueManager::put`

[](#supported-options-to-queuemanagerput-2)

- `topic` - A `string` with the url of a queue.
- `queue` - A `string` with the name of a queue in the config.

### Periodic

[](#periodic)

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

#### Usage

[](#usage-3)

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

#### Config

[](#config-4)

```
mcfedr_queue_manager:
    managers:
        periodic:
            driver: periodic
            options:
                default_manager: delay
                default_manager_options: []
```

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

- `default_manager` - Default job processor, must support delayed jobs, for example [Doctrine Delay](https://packagist.org/packages/mcfedr/doctrine-delay-queue-driver-bundle).
- `default_manager_options` - Default options to pass to job processor `put`.

#### Supported options to `QueueManager::put`

[](#supported-options-to-queuemanagerput-3)

- `period` - The average number of seconds between job runs.
- `manager` - Use a different job processor for this job.
- `manager_options` - Options to pass to the processors `put` method.

### Doctrine Delay

[](#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

[](#usage-4)

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.

```
./bin/console mcfedr:queue:{name}-runner
```

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

#### Config

[](#config-5)

```
mcfedr_queue_manager:
    managers:
        delay:
            driver: doctrine_delay
            options:
                entity_manager: default
                default_manager: default
                default_manager_options: []
```

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

- `entity_manager` - Doctrine entity manager to use.
- `default_manager` - Default job processor.
- `default_manager_options` - Default options to pass to job processor `put`.

#### Supported options to `QueueManager::put`

[](#supported-options-to-queuemanagerput-4)

- `time` - A `\DateTime` object of when to schedule this job.
- `delay` - Number of seconds from now to schedule this job.
- `force_delay` - A boolean that forces the job to be delayed by the specified number of seconds.
- `manager` - Use a different job processor for this job.
- `manager_options` - Options to pass to the processors `put` method.

#### Note

[](#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

[](#tables)

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

### Additional options

[](#additional-options)

These are the defaults for a number of other options.

```
mcfedr_queue_manager:
    retry_limit: 3
    sleep_seconds: 5
    report_memory: false
    doctrine_reset: true
```

OptionMeans`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

[](#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](https://symfony.com/doc/current/service_container/lazy_services.html).

```
composer require proxy-manager-bridge
```

Usage
-----

[](#usage-5)

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)

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.

```
Worker:
  tags:
  - { name: 'mcfedr_queue_manager.worker', id: 'test_worker' }
```

Now you can schedule this job with both:

```
$queueManager->put(Worker::class, ...)
$queueManager->put('test_worker', ...)
```

Events
------

[](#events)

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

NameEvent Objectmcfedr\_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
------------------------

[](#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

[](#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.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Recently: every ~73 days

Total

79

Last Release

646d ago

Major Versions

2.3.0 → 3.0.02016-07-28

3.3.3 → 4.0.02016-07-29

4.1.0 → 5.0.02016-08-04

5.10.0 → 6.0.02018-10-16

6.8.1 → 7.0.02023-12-06

PHP version history (5 changes)1.0.0PHP &gt;=5.4.0

2.0.0PHP &gt;=5.5

5.10.0PHP &gt;=7.2

6.6.0PHP &gt;=7.2.5

6.8.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7039999f29a83140d61116032ec1684c752412e458ad1999e15eea2f8808498c?d=identicon)[mcfedr](/maintainers/mcfedr)

---

Top Contributors

[![mcfedr](https://avatars.githubusercontent.com/u/704356?v=4)](https://github.com/mcfedr "mcfedr (159 commits)")[![nonanerz](https://avatars.githubusercontent.com/u/19575167?v=4)](https://github.com/nonanerz "nonanerz (19 commits)")[![gurman](https://avatars.githubusercontent.com/u/4621558?v=4)](https://github.com/gurman "gurman (2 commits)")[![ruslankovalov](https://avatars.githubusercontent.com/u/5740701?v=4)](https://github.com/ruslankovalov "ruslankovalov (1 commits)")

---

Tags

beanstalkdphpresquescheduled-jobssqssymfonyawsdoctrinequeuejobschedulebeanstalkdsqstaskpub-subgcp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mcfedr-queue-manager-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/mcfedr-queue-manager-bundle/health.svg)](https://phpackages.com/packages/mcfedr-queue-manager-bundle)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M305](/packages/laravel-horizon)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[mmucklo/queue-bundle

Symfony2/3/4/5 Queue Bundle (for background jobs) supporting Mongo (Doctrine ODM), Mysql (and any Doctrine ORM), RabbitMQ, Beanstalkd, Redis, and ... {write your own}

121942.6k](/packages/mmucklo-queue-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

9410.8k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
