PHPackages                             lamoda/queue-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. [Queues &amp; Workers](/categories/queues)
4. /
5. lamoda/queue-bundle

AbandonedArchivedLibrary[Queues &amp; Workers](/categories/queues)

lamoda/queue-bundle
===================

Symfony queue bundle

3.0.0(4y ago)1126162MITPHPPHP &gt;=7.2.0

Since Mar 20Pushed 4y ago4 watchersCompare

[ Source](https://github.com/lamoda/queue-bundle)[ Packagist](https://packagist.org/packages/lamoda/queue-bundle)[ RSS](/packages/lamoda-queue-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (15)Versions (23)Used By (2)

Lamoda Queue Bundle
===================

[](#lamoda-queue-bundle)

[![Build Status](https://camo.githubusercontent.com/34a63f903afe69ea4ba68380fd754b9891df85f39f2f1fbd1c29b43e71add81a/68747470733a2f2f7472617669732d63692e6f72672f6c616d6f64612f71756575652d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lamoda/queue-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a56008d0773daff633032ebd0e1327012001f18ad3320fba55781bc853e0b27d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c616d6f64612f71756575652d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lamoda/queue-bundle/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/b6e4c0ef40711b76963def7bd0ca62c2059fc181ebfb1f572afe6978a0785b26/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c616d6f64612f71756575652d62756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lamoda/queue-bundle/?branch=master)[![Build Status](https://camo.githubusercontent.com/a86fce05b64000b0197b190a473251f83a2dc144a4dbc0fa65f24c1667b1cddb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c616d6f64612f71756575652d62756e646c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lamoda/queue-bundle/build-status/master)

Symfony bundle for convenient work with queues. Currently it supports RabbitMQ.

Installation
------------

[](#installation)

1. Install bundle

    ```
    composer require lamoda/queue-bundle
    ```
2. Extend `Lamoda\QueueBundle\Entity\QueueEntityMappedSuperclass`

    ```
    use Doctrine\ORM\Mapping as ORM;
    use Lamoda\QueueBundle\Entity\QueueEntityMappedSuperclass;

    /**
     * @ORM\Entity(repositoryClass="Lamoda\QueueBundle\Entity\QueueRepository")
     */
    class Queue extends QueueEntityMappedSuperclass
    {
    }
    ```
3. Configure bundle parameters

    ```
    lamoda_queue:
        ## required
        entity_class: App\Entity\Queue
        max_attempts: 5
        batch_size_per_requeue: 5
        batch_size_per_republish: 5
        ## optional (will use for default delay Geometric Progression Strategy)
        strategy_delay_geometric_progression_start_interval_sec: 60
        strategy_delay_geometric_progression_multiplier: 2
    ```
4. Register bundle

    ```
    class AppKernel extends Kernel
    {
        // ...

        public function registerBundles()
        {
            $bundles = [
                // ...
                new Lamoda\QueueBundle\LamodaQueueBundle(),
                // ...
            ];

            return $bundles;
        }

        // ...
    }
    ```

    or add to `config/bundles.php`

    ```
    return [
        // ...
        Lamoda\QueueBundle\LamodaQueueBundle::class => ['all' => true],
        // ...
    ];
    ```
5. Migrate schema

    1. `doctrine:migrations:diff ` to create migration for `queue` table
    2. `doctrine:migrations:migrate` - apply the migration

Setup
-----

[](#setup)

### Create new exchange

[](#create-new-exchange)

1. Define new exchange constant

    ```
    namespace App\Constant;

    class Exchanges
    {
        public const DEFAULT = 'default';
    }
    ```
2. Add new node to `old_sound_rabbit_mq.producers` with previous defined constant name, example:

    ```
    old_sound_rabbit_mq:
        producers:
            default:
                connection: default
                exchange_options:
                    name: !php/const App\Constant\Exchanges::DEFAULT
                    type: "direct"
    ```

### Create new queue

[](#create-new-queue)

1. Define new queue constant

    ```
    namespace App\Constant;

    class Queues
    {
        public const NOTIFICATION = 'notification';
    }
    ```
2. Register consumer for queue in `old_sound_rabbit_mq.consumers` with previous defined constant name, example:

    ```
    old_sound_rabbit_mq:
        consumers:
            notification:
                connection: default
                exchange_options:
                    name: !php/const App\Constant\Exchanges::DEFAULT
                    type: "direct"
                queue_options:
                    name: !php/const App\Constant\Queues::NOTIFICATION
                    routing_keys:
                      - !php/const App\Constant\Queues::NOTIFICATION
                callback: "lamoda_queue.consumer"
    ```
3. Create job class, extend `AbstractJob` by example:

    ```
    namespace App\Job;

    use App\Constant\Exchanges;
    use App\Constant\Queues;
    use Lamoda\QueueBundle\Job\AbstractJob;
    use JMS\Serializer\Annotation as JMS;

    class SendNotificationJob extends AbstractJob
    {
        /**
         * @var string
         *
         * @JMS\Type("int")
         */
        private $message;

        public function __construct(string $message)
        {
            $this->message = $message;
        }

        public function getDefaultQueue(): string
        {
            return Queues::NOTIFICATION;
        }

        public function getDefaultExchange(): string
        {
            return Exchanges::DEFAULT;
        }
    }
    ```
4. Create job handler, implement HandlerInterface by example:

    ```
    namespace App\Handler;

    use Lamoda\QueueBundle\Handler\HandlerInterface;
    use Lamoda\QueueBundle\QueueInterface;

    class SendNotificationHandler implements HandlerInterface
    {
        public function handle(QueueInterface $job): void
        {
            // implement service logic here
        }
    }
    ```
5. Tag handler at service container

    ```
    services:
        App\Handler\SendNotificationHandler:
            public: true
            tags:
                - { name: queue.handler, handle: App\Job\SendNotificationJob }
    ```
6. Configure delay strategy parameters (optional)

    ```
    lamoda_queue:
    ...
        queues:
            queue_one: 'delay_arithmetic_progression'
            queue_two: 'delay_special_geometric_progression'

    # Settings of special behaviors for Delay strategies (optional)
    services:
      lamoda_queue.strategy.delay.arithmetic_progression:
        class: Lamoda\QueueBundle\Strategy\Delay\ArithmeticProgressionStrategy
        tags:
          - { name: 'lamoda_queue_strategy', key: 'delay_arithmetic_progression' }
        arguments:
          - 60 # start_interval_sec parameter
          - 1700 # multiplier parameter

     lamoda_queue.strategy.delay.geometric_progression:
        class: Lamoda\QueueBundle\Strategy\Delay\GeometricProgressionStrategy
        tags:
          - { name: 'lamoda_queue_strategy', key: 'delay_special_geometric_progression' }
        arguments:
          - 70 # start_interval_sec parameter
          - 4 # multiplier parameter
    ```

    In this block, you can config special delay behaviors for each queue. For this, you have to register new services that use one of several base strategies (ArithmeticProgressionStrategy, GeometricProgressionStrategy) or yours (for this you have to make Service Class that implements DelayStrategyInterface).

    Each strategy service has to have a tag with name `lamoda_queue_strategy` and unique `key`. After this, you can use these `keys` for matching with queues in `lamoda_queue.queues` section.

    By default, use GeometricProgressionStrategy with params (their you can customize in `lamoda_queue` config section):

    ```
        strategy_delay_geometric_progression_start_interval_sec: 60
        strategy_delay_geometric_progression_multiplier: 2

    ```
7. Add queue name in "codeception.yml" at `modules.config.AMQP.queues`
8. Execute `./bin/console queue:init` command

Usage
-----

[](#usage)

### Init exchange and queues

[](#init-exchange-and-queues)

```
./bin/console queue:init

```

### Add job to queue

[](#add-job-to-queue)

```
$job = new SendNotificationJob($id);
$container->get(Lamoda\QueueBundle\Factory\PublisherFactory::class)->publish($job);
```

### Run queued job

[](#run-queued-job)

```
./bin/console queue:consume notification

```

### Requeue failed queues

[](#requeue-failed-queues)

```
./bin/console queue:requeue

```

Advanced usage
--------------

[](#advanced-usage)

You can queue any primitive class, just implement `QueueInterface`:

```
namespace App\Process;

use Lamoda\QueueBundle\Entity\QueueInterface;

class MyProcess implements QueueInterface
{
    // implement interface functions
}
```

```
services:
    App\Handler\MyProcessHandler:
        public: true
        tags:
            - { name: queue.handler, handle: App\Process\MyProcess }
```

```
$process = new MyProcess();
$container->get('queue.publisher')->publish($process);
```

How to rerun queues
-------------------

[](#how-to-rerun-queues)

If you want to rerun queue, throw `Lamoda\QueueBundle\Exception\RuntimeException`.

If you want mark queue as failed, throw any another kind of exception.

```
namespace App\Handler;

use Lamoda\QueueBundle\Handler\HandlerInterface;
use Lamoda\QueueBundle\QueueInterface;

class SendNotificationHandler implements HandlerInterface
{
    public function handle(QueueInterface $job): void
    {
        // implement service logic here

        // Rerun queue
        if ($rerun === true) {
            throw new Lamoda\QueueBundle\Exception\RuntimeException('Error message');
        }

        // Mark queue as failed
        if ($failed === true) {
            throw new \Exception();
        }
    }
}
```

By default delay time is calculated exponentially. You can affect it through configuration.

```
lamoda_queue:
  ## required
  ## ...
  max_attempts: 5
  ## optional
  strategy_delay_geometric_progression_start_interval_sec: 60
  strategy_delay_geometric_progression_multiplier: 2
```

Events
------

[](#events)

### Lamoda\\QueueBundle\\Event\\QueueAttemptsReachedEvent

[](#lamodaqueuebundleeventqueueattemptsreachedevent)

When consumer wants to execute reached maximum attempts queue.

Properties:

- Queue Entity `QueueAttemptsReachedEvent::getQueue()`

Development
-----------

[](#development)

### PHP Coding Standards Fixer

[](#php-coding-standards-fixer)

```
make php-cs-check
make php-cs-fix
```

### Tests

[](#tests)

Unit

```
make test-unit
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 52.4% 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 ~73 days

Recently: every ~153 days

Total

14

Last Release

1702d ago

Major Versions

1.2.0 → 2.0.02020-01-29

2.2.2 → 3.0.02021-11-01

PHP version history (2 changes)1.0.0PHP &gt;=7.1.0

3.0.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4680327?v=4)[Anton Trekov](/maintainers/AntonTrekov)[@AntonTrekov](https://github.com/AntonTrekov)

---

Top Contributors

[![AntonTrekov](https://avatars.githubusercontent.com/u/4680327?v=4)](https://github.com/AntonTrekov "AntonTrekov (11 commits)")[![dedpikhto](https://avatars.githubusercontent.com/u/3489952?v=4)](https://github.com/dedpikhto "dedpikhto (3 commits)")[![medliii](https://avatars.githubusercontent.com/u/1991105?v=4)](https://github.com/medliii "medliii (2 commits)")[![Tekill](https://avatars.githubusercontent.com/u/965890?v=4)](https://github.com/Tekill "Tekill (2 commits)")[![Vabogco](https://avatars.githubusercontent.com/u/51154232?v=4)](https://github.com/Vabogco "Vabogco (1 commits)")[![tzepart](https://avatars.githubusercontent.com/u/10636031?v=4)](https://github.com/tzepart "tzepart (1 commits)")[![grachevko](https://avatars.githubusercontent.com/u/8628465?v=4)](https://github.com/grachevko "grachevko (1 commits)")

---

Tags

asynclamoda-queuephpphp-asyncqueuerabbitmqsymfonysymfony-bundle

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9417.2k55](/packages/open-dxp-opendxp)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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