PHPackages                             rsqueue/rsqueue-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. [Caching](/categories/caching)
4. /
5. rsqueue/rsqueue-bundle

ActiveSymfony-bundle[Caching](/categories/caching)

rsqueue/rsqueue-bundle
======================

Redis Symfony2 Queue Bundle, a simple and soft redis based message queue for symfony2

0.1.1(7y ago)1111.9k2[3 PRs](https://github.com/RSQueue/RSQueueBundle/pulls)1MITPHPPHP &gt;=7.1

Since Jan 31Pushed 6y ago3 watchersCompare

[ Source](https://github.com/RSQueue/RSQueueBundle)[ Packagist](https://packagist.org/packages/rsqueue/rsqueue-bundle)[ RSS](/packages/rsqueue-rsqueue-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (11)Versions (3)Used By (1)

RSQueueBundle for Symfony
=========================

[](#rsqueuebundle-for-symfony)

### Simple queuing system based on Redis

[](#simple-queuing-system-based-on-redis)

[![SensioLabsInsight](https://camo.githubusercontent.com/4440e9de7c6270e6bb48e7efeec88d36df9354c2a6957210ce5ea8a18a9da6c6/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f37383933316164382d623031362d346235622d396234352d6335613537363766626439652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/78931ad8-b016-4b5b-9b45-c5a5767fbd9e)[![Build Status](https://camo.githubusercontent.com/eca0c902c9b9f791f1acca6a27aafd86891b5cd42f550612199ff6e89f1c933a/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6d6d6f726572616d2f5253517565756542756e646c652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/mmoreram/rsqueue-bundle)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/f5c2fb97308baa195dea45f2ce0c1c4acee6fa2fec4c37c283fba64312864313/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6d6f726572616d2f5253517565756542756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f733d32393066393034666631346662373264396434303238383638323934396233646538386639396639)](https://scrutinizer-ci.com/g/mmoreram/RSQueueBundle/)

Table of contents
-----------------

[](#table-of-contents)

1. [Installing/Configuring](#installingconfiguring)
    - [Tags](#tags)
    - [Installing Redis](#installing-redis)
    - [Installing PHPRedis](#installing-phpredis)
    - [Installing RSQueue](#installing-rsqueue)
    - [Configuration](#configuration)
2. [Producers/Consumers](#producersconsumers)
3. [Publishers/Subscribers](#publisherssubscribers)
4. [Events](#events)
5. [Contributing](#contributing)

Installing/Configuring
----------------------

[](#installingconfiguring)

Tags
----

[](#tags)

- Use version `1.0-dev` for last updated. Alias of `dev-master`.
- Use last stable version tag to stay in a stable release.

Installing [Redis](http://redis.io)
-----------------------------------

[](#installing-redis)

```
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
```

Installing [PHPRedis](https://github.com/nicolasff/phpredis)
------------------------------------------------------------

[](#installing-phpredis)

phpredis extension is necessary to be installed in your server.
Otherwise composer will alert you.

```
git clone git://github.com/nicolasff/phpredis.git
cd phpredis
phpize
./configure
make
sudo make install
cd ..
echo "extension=redis.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
```

Installing [RSQueue](http://rsqueue.com)
----------------------------------------

[](#installing-rsqueue)

You have to add require line into you composer.json file

```
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",
    ...
    "mmoreram/rsqueue-bundle": "dev-master"
},
```

Then you have to use composer to update your project dependencies

```
php composer.phar update
```

And register the bundle in your appkernel.php file

```
return array(
    // ...
    new Mmoreram\RSQueueBundle\RSQueueBundle(),
    // ...
);
```

Configuration
-------------

[](#configuration)

In this first version, all conections are localhost:6379, but as soon as posible connections will be configurable.
You need to configure all queues and serializer.
By default serializer has the value 'Json', but also 'PHP' value can be used. Also custom serializer can be implemented by extending default serializer interface. Then you need to add namespace of class into the rs\_queue.serializer parameter.

```
rs_queue:

    # Queues definition
    queues:
        videos: "queues:videos"
        audios: "queues:audios"

    # Serializer definition
    serializer: ~

    # Server configuration. By default, these values
    server:
        redis:
            host: 127.0.0.1
            port: 6379
            database: ~
```

Producers/Consumers
-------------------

[](#producersconsumers)

Producer/consumer model allows you to produce elements into one/many queues by using default rsqueue producer service.
One element is pushed into one queue so one and only one consumer will pop and treat this element.

```
$this->container->get("rs_queue.producer")->produce("videos", "this is my video");
$this->container->get("rs_queue.producer")->produce("audios", "this is my audio");
```

Then you should extend ConsumerCommand so that in this way you can define which queues listen, and in each case, which action execute.

```
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Mmoreram\RSQueueBundle\Command\ConsumerCommand;

/**
 * Testing consumer command
 */
class TestConsumerCommand extends ConsumerCommand
{

    /**
     * Configuration method
     */
    protected function configure()
    {
        $this
            ->setName('test:consumer')
            ->setDescription('Testing consumer command');
        ;

        parent::configure();
    }

    /**
     * Relates queue name with appropiated method
     */
    public function define()
    {
        $this->addQueue('videos', 'consumeVideo');
    }

    /**
     * If many queues are defined, as Redis respects order of queues, you can shuffle them
     * just overwritting method shuffleQueues() and returning true
     *
     * @return boolean Shuffle before passing to Gearman
     */
    public function shuffleQueues()
    {
        return true;
    }

    /**
     * Consume method with retrieved queue value
     *
     * @param InputInterface  $input   An InputInterface instance
     * @param OutputInterface $output  An OutputInterface instance
     * @param Mixed           $payload Data retrieved and unserialized from queue
     */
    protected function consumeVideo(InputInterface $input, OutputInterface $output, $payload)
    {
        $output->writeln($payload);
    }
}
```

Publishers/Subscribers
----------------------

[](#publisherssubscribers)

This model allows data broadcasting. This means that one or more Subscribers will treat all elements of the queue, but only if they are listening just in the moment publisher publish them.

```
$this->container->get("rs_queue.publisher")->publish("audios", "this is my audio");
```

And, as consumers, subscribers must define which channels they want to listen

```
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Mmoreram\RSQueueBundle\Command\SubscriberCommand;

/**
 * Testing subscriber command
 */
class TestSubscriberCommand extends SubscriberCommand
{

    /**
     * Configuration method
     */
    protected function configure()
    {
        $this
            ->setName('test:subscriber:audios')
            ->setDescription('Testing subscriber audios command');
        ;

        parent::configure();
    }

    /**
     * Relates queue name with appropiated method
     */
    public function define()
    {
        $this->addChannel('audios', 'consumeAudio');
    }

    /**
     * If many queues are defined, as Redis respects order of queues, you can shuffle them
     * just overwritting method shuffleQueues() and returning true
     *
     * @return boolean Shuffle before passing to Gearman
     */
    public function shuffleQueues()
    {
        return true;
    }

    /**
     * subscriber method with retrieved queue value
     *
     * @param InputInterface  $input   An InputInterface instance
     * @param OutputInterface $output  An OutputInterface instance
     * @param Mixed           $payload Data retrieved and unserialized from queue
     */
    protected function consumeAudio(InputInterface $input, OutputInterface $output, $payload)
    {
        $output->writeln($payload);
    }
}
```

By extending PSubscriberCommand you can define patterns instead of queue names.

```
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Mmoreram\RSQueueBundle\Command\PSubscriberCommand;

/**
 * Testing PSubscriber command
 */
class TestPSubscriberCommand extends PSubscriberCommand
{

    /**
     * Configuration method
     */
    protected function configure()
    {
        $this
            ->setName('test:psubscriber')
            ->setDescription('Testing psubscriber command');
        ;

        parent::configure();
    }

    /**
     * Relates queue name with appropiated method
     */
    public function define()
    {
        $this->addPattern('*', 'consumeAll');
    }

    /**
     * If many queues are defined, as Redis respects order of queues, you can shuffle them
     * just overwritting method shuffleQueues() and returning true
     *
     * @return boolean Shuffle before passing to Gearman
     */
    public function shuffleQueues()
    {
        return true;
    }

    /**
     * Consume method with retrieved queue value
     *
     * @param InputInterface  $input   An InputInterface instance
     * @param OutputInterface $output  An OutputInterface instance
     * @param Mixed           $payload Data retrieved and unserialized from queue
     */
    protected function consumeAll(InputInterface $input, OutputInterface $output, $payload)
    {
        $output->writeln($payload);
    }
}
```

Events
------

[](#events)

Custom events are used in this bundle.

```
/**
 * The rs_queue.consumer is thrown each time a job is consumed by consumer
 *
 * The event listener recieves an
 * Mmoreram\RSQueueBundle\Event\RSQueueConsumerEvent instance
 *
 * @var string
 */
const RSQUEUE_CONSUMER = 'rs_queue.consumer';

/**
 * The rs_queue.subscriber is thrown each time a job is consumed by subscriber
 *
 * The event listener recieves an
 * Mmoreram\RSQueueBundle\Event\RSQueueSubscriberEvent instance
 *
 * @var string
 */
const RSQUEUE_SUBSCRIBER = 'rs_queue.subscriber';

/**
 * The rs_queue.producer is thrown each time a job is consumed by producer
 *
 * The event listener recieves an
 * Mmoreram\RSQueueBundle\Event\RSQueueProducerEvent instance
 *
 * @var string
 */
const RSQUEUE_PRODUCER = 'rs_queue.producer';

/**
 * The rs_queue.publisher is thrown each time a job is consumed by publisher
 *
 * The event listener recieves an
 * Mmoreram\RSQueueBundle\Event\RSQueuePublisherEvent instance
 *
 * @var string
 */
const RSQUEUE_PUBLISHER = 'rs_queue.publisher';
```

Contributing
------------

[](#contributing)

All code is Symfony2 Code formatted, so every pull request must validate phpcs standards. You should read [Symfony2 coding standards](http://symfony.com/doc/current/contributing/code/standards.html)and install [this](https://github.com/opensky/Symfony2-coding-standard)CodeSniffer to check all code is validated.

There is also a policy for contributing to this project. All pull request must be all explained step by step, to make us more understandable and easier to merge pull request. All new features must be tested with PHPUnit.

If you'd like to contribute, please read the [Contributing Code](http://symfony.com/doc/current/contributing/code/index.html) part of the documentation. If you're submitting a pull request, please follow the guidelines in the [Submitting a Patch](http://symfony.com/doc/current/contributing/code/patches.html#check-list) section and use the [Pull Request Template](http://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.9% 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 ~249 days

Total

2

Last Release

2777d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8cb88fa6413489c9cdb77288a06ff94b4553aa497d8fc0ee1891576053f1306?d=identicon)[mmoreram](/maintainers/mmoreram)

---

Top Contributors

[![mmoreram](https://avatars.githubusercontent.com/u/521409?v=4)](https://github.com/mmoreram "mmoreram (65 commits)")[![kuldipem](https://avatars.githubusercontent.com/u/2017625?v=4)](https://github.com/kuldipem "kuldipem (3 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")[![dpcat237](https://avatars.githubusercontent.com/u/388031?v=4)](https://github.com/dpcat237 "dpcat237 (1 commits)")

---

Tags

symfonyredisqueuersqueue

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[mmoreram/rsqueue-bundle

Redis Symfony2 Queue Bundle, a simple and soft redis based message queue for symfony2

5360.7k1](/packages/mmoreram-rsqueue-bundle)[scheb/2fa-bundle

A generic interface to implement two-factor authentication in Symfony applications

6914.0M62](/packages/scheb-2fa-bundle)

PHPackages © 2026

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