PHPackages                             howincodes/laravel-rabbitmq - 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. howincodes/laravel-rabbitmq

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

howincodes/laravel-rabbitmq
===========================

A Laravel RabbitMQ wrapper with automatic dead-letter retry

v1.1.4(10mo ago)05MITPHPPHP ^8.0

Since Jul 15Pushed 10mo agoCompare

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

READMEChangelogDependencies (2)Versions (7)Used By (0)

📦 howincodes/laravel-rabbitmq
=============================

[](#-howincodeslaravel-rabbitmq)

A **Laravel-first** RabbitMQ wrapper that auto-configures dead-letter retry queues so you can focus on writing your handlers—no boilerplate required! 🎉

---

🚀 Installation
--------------

[](#-installation)

```
# 1️⃣ Install via Composer
composer require howincodes/laravel-rabbitmq

# 2️⃣ Publish the default config
php artisan vendor:publish \
  --provider="HowinCodes\RabbitMQ\RabbitMQServiceProvider" \
  --tag="config"
```

This publishes `config/rabbitmq.php` into your app.

---

⚙️ Configuration
----------------

[](#️-configuration)

Open `config/rabbitmq.php` and you’ll see:

```
return [

    // 🖥️ Broker Connection
    'host'     => env('RABBITMQ_HOST', '127.0.0.1'),
    'port'     => env('RABBITMQ_PORT', 5672),
    'user'     => env('RABBITMQ_USER', 'guest'),
    'password' => env('RABBITMQ_PASSWORD', 'guest'),
    'vhost'    => env('RABBITMQ_VHOST', '/'),

    // 🔄 Base exchanges
    'exchanges' => [
        'tasks' => [
            'type'    => 'topic',
            'durable' => true,
        ],
        // add your own exchanges here...
    ],

    // 📬 Queues + Retry settings
    'queues' => [
        'tasks' => [
            'exchange'     => 'tasks',
            'routing_keys' => ['task.created'],
            'durable'      => true,
            'consume'      => true,

            // ⚙️ Enable retry logic
            'retry'        => [
                'enabled'      => true,
                'max_attempts' => 5,      # total tries before giving up
                'interval'     => 15000,  # wait 15s before retry (ms)
            ],
        ],
        // `tasks.retry` auto-generated by the package
    ],

    // 🛠️ Map queue names → handler classes
    'queue_handlers' => [
        'tasks'       => HowinCodes\RabbitMQ\Handlers\GenericHandler::class,
        'tasks.retry' => HowinCodes\RabbitMQ\Handlers\GenericRetryHandler::class,
    ],
];
```

> **Tip:**Feel free to rename `tasks` to anything—each base queue can have its own retry block!

---

📚 How It Works
--------------

[](#-how-it-works)

1. **Declare your base queue**

    - One config block, no need to manually define DLX or retry queue.
2. **Package auto-generates**

    - `.retry` exchange
    - `.retry` queue with TTL &amp; DLX back to your base exchange
3. **Handlers**

    - `GenericHandler` processes the main queue.
    - `GenericRetryHandler` processes messages after they exceed retries.

---

🎨 Usage
-------

[](#-usage)

### 1. Publishing a Message

[](#1-publishing-a-message)

```
use HowinCodes\RabbitMQ\Publisher;

app(Publisher::class)
    ->publish('tasks', 'task.created', [
        'id'      => 123,
        'payload' => ['foo' => 'bar'],
    ]);
```

💡 The `tasks` exchange is declared automatically.

---

### 2. Running the Consumer

[](#2-running-the-consumer)

```
php artisan rabbitmq:consume-queues
```

✔️ Listens on **both** `tasks` and `tasks.retry` queues 🛠️ Dispatches to `GenericHandler` &amp; `GenericRetryHandler`

---

🧑‍🤝‍🧑 Examples
--------------

[](#‍‍-examples)

### A. Tasks Queue (Default)

[](#a-tasks-queue-default)

- **Exchange:** `tasks`
- **Queue:** `tasks` → retry to `tasks.retry`
- **Handlers:**

    - `GenericHandler`
    - `GenericRetryHandler`

```
// config/rabbitmq.php snippet:
'queues' => [
    'tasks' => [
        'exchange'     => 'tasks',
        'routing_keys' => ['task.created'],
        'retry'        => ['enabled'=>true,'max_attempts'=>5,'interval'=>15000],
    ],
],
'queue_handlers' => [
    'tasks'       => GenericHandler::class,
    'tasks.retry' => GenericRetryHandler::class,
],
```

---

### B. User Events Queue

[](#b-user-events-queue)

```
// config/rabbitmq.php snippet:
'exchanges' => [
    'users' => ['type'=>'topic','durable'=>true],
],
'queues' => [
    'users' => [
        'exchange'     => 'users',
        'routing_keys' => ['user.created','user.updated','user.deleted'],
        'retry'        => ['enabled'=>true,'max_attempts'=>3,'interval'=>10000],
    ],
],
'queue_handlers' => [
    'users'       => GenericHandler::class,
    'users.retry' => GenericRetryHandler::class,
],
```

**Publishing:**

```
app(Publisher::class)
    ->publish('users', 'user.created', [
        'id'    => 456,
        'name'  => 'Alice',
        'email' => 'alice@example.com',
    ]);
```

**Consuming:**

```
php artisan rabbitmq:consume-queues
```

---

🛠️ Customization &amp; Advanced
-------------------------------

[](#️-customization--advanced)

- **Custom Handlers:**Swap `GenericHandler` and `GenericRetryHandler` for your own classes in `config/rabbitmq.php`.
- **Custom DLX Names:**Override `'exchange'` or `'routing_key'` in the `retry` block.
- **Disable Retry:**`'retry' => ['enabled' => false]` or remove the `retry` block.
- **Monitoring:**Use Laravel logging, Sentry, or other APM to track dead-letter flows.

---

❤️ Thank You!
-------------

[](#️-thank-you)

Thanks for choosing **howincodes/laravel-rabbitmq**! If you love it, ⭐ star the repo and share your feedback. Happy messaging! 🚀

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance55

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

Every ~0 days

Total

6

Last Release

301d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cc62a30dc9e7a6e04102e2d2aea38b75484cf7db9c8c7636d7208addbeccaba?d=identicon)[howincodes](/maintainers/howincodes)

---

Top Contributors

[![farisbasha](https://avatars.githubusercontent.com/u/72191505?v=4)](https://github.com/farisbasha "farisbasha (9 commits)")

---

Tags

laravelqueuerabbitmqAMQP

### Embed Badge

![Health badge](/badges/howincodes-laravel-rabbitmq/health.svg)

```
[![Health](https://phpackages.com/badges/howincodes-laravel-rabbitmq/health.svg)](https://phpackages.com/packages/howincodes-laravel-rabbitmq)
```

###  Alternatives

[bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2752.3M7](/packages/bschmitt-laravel-amqp)[nuwber/rabbitevents

The Nuwber RabbitEvents package

120515.8k3](/packages/nuwber-rabbitevents)[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)

PHPackages © 2026

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