PHPackages                             tahseen9/rabbit-queue - 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. tahseen9/rabbit-queue

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

tahseen9/rabbit-queue
=====================

A laravel package to dispatch and listen Rabbit MQ Queues in a simple way!

1.0.0(2y ago)0195MITPHPPHP &gt;=7.2

Since Dec 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tahseen9/rabbit-queue)[ Packagist](https://packagist.org/packages/tahseen9/rabbit-queue)[ RSS](/packages/tahseen9-rabbit-queue/feed)WikiDiscussions main Synced 1mo ago

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

Rabbit Queue (Laravel Package)
==============================

[](#rabbit-queue-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b8b65d74269acf1d7e0ea07014a047f7d5978b29c566cf9575c9dabec5c189dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7461687365656e392f7261626269742d71756575652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tahseen9/rabbit-queue)

A simple and elegant [Laravel](https://laravel.com) wrapper around [php-amqplib](https://github.com/php-amqplib/php-amqplib) for dispatching to and listening from [rabbitmq](https://www.rabbitmq.com/) queues.

### Avoiding High Connection Churn

[](#avoiding-high-connection-churn)

Use [AMQProxy](https://laravel.com), which is a proxy library with connection and channel pooling/reusing. This allows for lower connection and channel churn when using php-amqplib, leading to less CPU usage of RabbitMQ.

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

[](#installation)

#### Via Dependency Composer

[](#via-dependency-composer)

```
composer require tahseen9/rabbit-queue
```

#### Publish assets (config file)

[](#publish-assets-config-file)

```
php artisan vendor:publish --provider="Tahseen9\RabbitQueue\RabbitQueueServiceProvider"
```

Usage
-----

[](#usage)

### Dispatch Queue

[](#dispatch-queue)

#### Via Dependency Injection

[](#via-dependency-injection)

```
use Tahseen9\RabbitQueue\Contracts\T9RMQProducerInterface;

class MyProducer {

    private string $exchange = 'my_exchange';

    private string $queue = 'my_queue';

    private T9RMQConsumerInterface $producer;

    public function __construct(T9RMQProducerInterface $producer){
        # you can define the exchange and queue here
        $this->producer = $producer->setExchange($this->producer)
                                   ->onQueue($this->queue);
       # if you are running multiple queues,
       # pass the queue name in second argument of dispatch method like shown in the facade section
    }

    public function fooProducer() {

        $this-producer->dispatch([
          'lang' => 'php',
          'framework' => 'laravel',
        ]); # return type void

    } # fooProducer end
} # class end
```

#### Via Facade

[](#via-facade)

```
use Tahseen9\RabbitQueue\Facades\RabbitQueue;
...

RabbitQueue::dispatch(
    [
      'lang' => 'php',
      'framework' => 'laravel',
    ], # Message Array
    $queue_name = "my_queue" # Queue Name
 ); # return type void
```

### Listen Queue

[](#listen-queue)

#### Via Dependency Injection

[](#via-dependency-injection-1)

```
use Tahseen9\RabbitQueue\Contracts\T9RMQConsumerInterface;

class MyListener {

    private string $exchange = 'my_exchange';

    private string $queue = 'my_queue';

    private T9RMQConsumerInterface $consumer;

    public function __construct(T9RMQConsumerInterface $consumer){

        # you can define the exchange and queue explicitly here
        $this->consumer = $consumer->setExchange($this->exchange)
                                   ->onQueue($this->queue);
       # if you are running multiple queues,
       # pass the queue name in second argument of listen method like shown in the facade section

    }

    public function barListener() {

        $this-consumer->jsonArray(true) # want json array, set true, default null : used json_encode() inside
        ->listen(function($message, $handler){

            echo $message['lang']; # php
            echo $message['framework']; # laravel

            $handler->ack(); # acknowledge message after using it, so it will be removed from the queue

    #        $handler->stopWhenProcessed(); # use this if you want to stop execution after listening the whole queue

          }); # return type void

    } # barListener end
} # class end
```

#### Via Facade

[](#via-facade-1)

```
use Tahseen9\RabbitQueue\Facades\RabbitQueue;
...

RabbitQueue::listen(function($message, $handler){

    echo $message->lang; # php
    echo $message->framework; # laravel

    $handler->ack(); # acknowledge message after using it, so it will be removed from the queue

#    $handler->stopWhenProcessed(); # use this if you want to stop execution after listening the whole queue

}, $queue_name = "my_queue"); # return type void
```

### Using via Class Instance

[](#using-via-class-instance)

```
 $rabbitQueue = new \Tahseen9\RabbitQueue\RabbitQueue();

 #available methods:
 $rabbitQueue->producer(); # returns producer instance
 $rabbitQueue->consumer(); # returns consumer instance

 # by default queue_name is nullable you can skip this param if set via method e.g.
 # $rabbitQueue->producer()->onQueue('my_queue')->dispatch($msg);
 # $rabbitQueue->consumer()->onQueue('my_queue')->listen(Closure $closure);

 $rabbitQueue->dispatch(array $message, string $queueName); # dispatch queue directly on default exchange
 $rabbitQueue->listen(Closure $closure, string $queueName); # start listening instantly on default exchange
```

### Configuration file (rabbit-queue.php)

[](#configuration-file-rabbit-queuephp)

```
#publish file with this command:
php artisan vendor:publish --provider="Tahseen9\RabbitQueue\RabbitQueueServiceProvider"

 env("RABBITMQ_HOST", "localhost"),
    "port" => env("RABBITMQ_PORT", "5672"),
    "username" => env("RABBITMQ_USERNAME", "guest"),
    "password" => env("RABBITMQ_PASSWORD", "guest"),

    # define exchange name or use method to define if dealing with multiple exchanges
    "exchange" => env("EXCHANGE_NAME", env("APP_NAME", "LARAVEL_RABBIT_EXCHANGE")),
    "exchange_type" => env("EXCHANGE_TYPE", "direct"), # this option is only available via env for now
    "exchange_passive" => false,
    "exchange_durable" => true, # persistent exchange
    "exchange_auto_delete" => false,

    "routing_key_postfix" => env("ROUTING_KEY_POSTFIX", "_key"),
    "consumer_tag_post_fix" => env("ROUTING_KEY_POSTFIX", "_tag"),

    "qos" => true, # this will apply prefetch count and prefetch size

    # These will work if qos is true
    "qos_prefetch_size" => 0, # unlimited multiple of prefetch count
    "qos_prefetch_count" => 1, # process 1 job by 1 worker at a time, increasing this number will pre load x amount of jobs in memory for worker
    "qos_a_global" => false,

    # Queue Declaration
    "queue_passive" => false,
    "queue_durable" => true, # persistent queue
    "queue_exclusive" => false,
    "queue_auto_delete" => false,

    # Consumer declaration
    "consumer_no_local" => false,
    "consumer_no_ack" => false, # default: must acknowledge else true
    "consumer_exclusive" => false,
    "consumer_no_wait" => false,

    "message_delivery_mode" => 2 // DELIVERY MODE PERSISTENT = 2 | DELIVERY MODE NON PERSISTENT = 1
];
```

Change log
----------

[](#change-log)

Version 1.0.0 Released

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- AMQProxy team
- php-amqplib team

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

893d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ce4e5c88273da7011fcfe61da36e94bac563160c83774d7e22fea69f26729ae?d=identicon)[tahseen9](/maintainers/tahseen9)

---

Top Contributors

[![tahseen9](https://avatars.githubusercontent.com/u/108788946?v=4)](https://github.com/tahseen9 "tahseen9 (10 commits)")

---

Tags

laravellaravel-queueslaravel rabbitmqRabbitQueueRabbit MQ implementation in laravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tahseen9-rabbit-queue/health.svg)

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

###  Alternatives

[bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2752.3M7](/packages/bschmitt-laravel-amqp)[convenia/pigeon

3233.0k](/packages/convenia-pigeon)[sokanacademy/laravel-fluent-rabbitmq

integrate rabbitmq in a laravel application

323.2k](/packages/sokanacademy-laravel-fluent-rabbitmq)[mookofe/tail

RabbitMQ and PHP client for Laravel and Lumen that allows you to add and listen queues messages just simple

5552.5k](/packages/mookofe-tail)[kunalvarma05/laravel-rabbitmq

Work with RabbitMQ in Laravel.

1853.7k](/packages/kunalvarma05-laravel-rabbitmq)[sobirjonovs/laravel-rabbit

Easy tool for working with RabbitMQ

111.6k](/packages/sobirjonovs-laravel-rabbit)

PHPackages © 2026

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