PHPackages                             paulemich/laravel-asb - 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. paulemich/laravel-asb

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

paulemich/laravel-asb
=====================

Azure Service Bus queue driver for Laravel (asb), supporting delay, retry/backoff and dead-lettering. Built on paulemich/azure-service-bus.

00PHP

Since Jun 3Pushed 1mo agoCompare

[ Source](https://github.com/PaulEmich/laravel-asb)[ Packagist](https://packagist.org/packages/paulemich/laravel-asb)[ RSS](/packages/paulemich-laravel-asb/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Azure Service Bus Queue Driver
======================================

[](#laravel-azure-service-bus-queue-driver)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dfcf6d23678aec64c27e94203857680cd5de99c8019d7537c7b34eb2825375f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7061756c656d6963682f6c61726176656c2d6173622e737667)](https://packagist.org/packages/paulemich/laravel-asb)[![Total Downloads](https://camo.githubusercontent.com/a4bbc29dd5fef4465c7e7052d3f8f4cc883477e5dd750da81d0087334b1cd466/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7061756c656d6963682f6c61726176656c2d6173622e737667)](https://packagist.org/packages/paulemich/laravel-asb)[![License](https://camo.githubusercontent.com/ff918231c126d6401f4bf60c7bf21341c6e41f33aafe281239d3f8d844a754eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7061756c656d6963682f6c61726176656c2d6173622e737667)](LICENSE.md)

An [Azure Service Bus](https://learn.microsoft.com/azure/service-bus-messaging/) queue driver for Laravel, registered as the `asb` connection — the Azure counterpart to Laravel's built-in `sqs` driver. It plugs straight into Laravel's queue system, so `dispatch()`, `->delay()`, `$tries`, `$backoff`, `release()`, `failed()`, and dead-lettering all work as you'd expect.

It talks to Service Bus over the **REST API** (no PHP extensions required) and is built on the framework-agnostic [`paulemich/azure-service-bus`](https://packagist.org/packages/paulemich/azure-service-bus) client.

Features
--------

[](#features)

Laravel featureHow it maps to Azure Service Bus`dispatch($job)`Message sent to the queue (peek-lock on receive)`->delay($seconds)` / `Queue::later()`Native `ScheduledEnqueueTimeUtc` scheduled delivery`$job->attempts()`Native `DeliveryCount`Retry after failureNative message **abandon** (immediately redelivered)`$tries` exhaustedHonoured by the worker; combine with the queue's `MaxDeliveryCount` for native dead-lettering`$backoff` (delayed retry)Reschedules the message with `ScheduledEnqueueTimeUtc`, carrying the attempt count forward`queue:clear`Drains the queue via destructive receiveRequirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 13+
- An Azure Service Bus namespace with a **queue** and a SAS policy that grants `Send` and `Listen` (and `Manage` if you want `queue:monitor` counts).

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

[](#installation)

```
composer require paulemich/laravel-asb
```

The service provider is auto-discovered and registers the `asb` queue connector.

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

[](#configuration)

The package ships with sensible, env-driven defaults that are merged into `queue.connections.asb`, so the quickest setup is just environment variables:

```
QUEUE_CONNECTION=asb

# Option A — a full connection string (copy it from the Azure portal):
ASB_CONNECTION_STRING="Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=your-key"

# Option B — discrete credentials (use one option or the other):
ASB_NAMESPACE=my-namespace            # short name OR full host (my-namespace.servicebus.windows.net)
ASB_KEY_NAME=RootManageSharedAccessKey
ASB_KEY=your-key

ASB_QUEUE=default                     # the queue (entity) to use
ASB_WAIT=30                           # peek-lock long-poll seconds
# ASB_TTL=3600                        # optional default message TTL (seconds)
# ASB_TOKEN_TTL=3600                  # SAS token lifetime (seconds)
```

If you prefer to manage everything in `config/queue.php` (the standard Laravel way), add an explicit connection block:

```
'connections' => [

    // ...

    'asb' => [
        'driver' => 'asb',
        'connection_string' => env('ASB_CONNECTION_STRING'),
        // or the discrete credentials:
        'namespace' => env('ASB_NAMESPACE'),
        'shared_access_key_name' => env('ASB_KEY_NAME'),
        'shared_access_key' => env('ASB_KEY'),

        'queue' => env('ASB_QUEUE', 'default'),
        'wait' => (int) env('ASB_WAIT', 30),
        'ttl' => env('ASB_TTL') !== null ? (int) env('ASB_TTL') : null,
        'token_ttl' => (int) env('ASB_TOKEN_TTL', 3600),
        'after_commit' => false,
    ],

],
```

When a `connection_string` is present it takes precedence; otherwise the discrete `namespace` / `shared_access_key_name` / `shared_access_key` are used. `namespace` accepts either a short name (`my-namespace`) or a fully-qualified host (`my-namespace.servicebus.windows.net`).

Usage
-----

[](#usage)

Use it like any other queue connection.

```
// Dispatch to the default ASB queue
ProcessPodcast::dispatch($podcast);

// Delay (native scheduled delivery)
ProcessPodcast::dispatch($podcast)->delay(now()->addMinutes(10));

// Target a specific queue
ProcessPodcast::dispatch($podcast)->onQueue('media');

// Run a worker against the connection
// php artisan queue:work asb
// php artisan queue:work asb --queue=media
```

Third-party package jobs work unchanged — the driver only wraps the transport envelope; your job class is serialized into the message payload exactly as with any other driver.

### Retries, backoff &amp; dead-lettering

[](#retries-backoff--dead-lettering)

There are two retry paths, and which one runs depends on whether the job asks for a delay:

- **Immediate retry** (a job released without a delay, e.g. a thrown exception with no `$backoff`): the message is **abandoned** natively. Service Bus increments `DeliveryCount` and redelivers it. This is fully native — set the queue's **`MaxDeliveryCount`** in Azure and exhausted messages are moved to the dead-letter sub-queue automatically.
- **Delayed retry** (`$backoff`, or `release($seconds)` with a delay): the Service Bus REST API cannot "abandon with a delay", so the driver schedules a fresh copy with `ScheduledEnqueueTimeUtc` and completes the original. The attempt count is carried forward in a custom message property so `attempts()` stays correct.

> **Tip:** For jobs that use `$backoff`, rely on Laravel's `$tries` / `retryUntil()` to bound retries rather than the queue's `MaxDeliveryCount`, since each delayed retry is a freshly scheduled message.

To enable native dead-lettering for the immediate-retry path, set **Max Delivery Count** on the queue in the Azure portal (Queue → Settings) or via your IaC of choice.

### Queue monitoring

[](#queue-monitoring)

`Queue::connection('asb')->size()` reports active + scheduled messages. `pendingSize()` and `delayedSize()` map to the active and scheduled counts respectively. Two methods return fixed values because Service Bus does not expose them over REST:

- `reservedSize()` always returns `0` (there is no locked/in-flight count).
- `creationTimeOfOldestPendingJob()` always returns `null`.

Reading counts requires a SAS policy with the `Manage` claim.

Artisan commands
----------------

[](#artisan-commands)

The package ships a few diagnostic commands for poking at a live queue and seeing exactly what the driver does. They all accept `--connection=` (default `asb`) and `--queue=` (defaults to the connection's configured queue).

```
# Show message counts: the driver methods (size/pending/delayed/reserved) and
# the raw Service Bus breakdown (active/scheduled/dead-letter/total).
php artisan asb:counts

# Send messages. Generates a JSON probe payload when no body is given.
php artisan asb:send                         # one probe message
php artisan asb:send '{"hello":"world"}'     # a literal body
php artisan asb:send --count=5 --delay=30    # five messages, scheduled 30s out
php artisan asb:send --property=Priority=high --property=Tenant=acme

# Peek-lock receive a single message and print its broker properties, custom
# properties and body. --ack controls settlement: abandon (default), complete, hold.
php artisan asb:receive --wait=10 --ack=complete

# Remove all available messages from the queue.
php artisan asb:purge
```

Testing
-------

[](#testing)

```
composer install
vendor/bin/pest
```

The suite uses [Orchestra Testbench](https://github.com/orchestral/testbench) and mocks the Service Bus client, so no Azure account or network access is needed.

License
-------

[](#license)

The MIT License (MIT). See [LICENSE.md](LICENSE.md).

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c5aba7c688cc3500f3ce2c46de86ed887be5d6a8c6cd3d0c119f090aec4068a?d=identicon)[PaulEmich](/maintainers/PaulEmich)

---

Top Contributors

[![PaulEmich](https://avatars.githubusercontent.com/u/1635879?v=4)](https://github.com/PaulEmich "PaulEmich (1 commits)")

### Embed Badge

![Health badge](/badges/paulemich-laravel-asb/health.svg)

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.6M31](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6046.3M586](/packages/illuminate-bus)[brave-sir-robin/amqphp

AMQP 0.9.1 Protocol Implementation in pure PHP

7932.8k](/packages/brave-sir-robin-amqphp)[belvg/module-sqs

N/A

1544.6k](/packages/belvg-module-sqs)[mayconbordin/l5-stomp-queue

Stomp Queue Driver for Laravel 5

121.1k](/packages/mayconbordin-l5-stomp-queue)

PHPackages © 2026

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