PHPackages                             freyr/message-broker - 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. freyr/message-broker

ActiveSymfony-bundle[Queues &amp; Workers](/categories/queues)

freyr/message-broker
====================

Reliable Inbox &amp; Outbox Patterns for Symfony Messenger with transactional guarantees and automatic deduplication

v0.4.0(2mo ago)277↓100%1[1 issues](https://github.com/freyr/message-broker/issues)MITPHPPHP &gt;=8.2CI passing

Since Oct 11Pushed 2mo ago1 watchersCompare

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

READMEChangelog (1)Dependencies (23)Versions (16)Used By (0)

Freyr Message Broker
====================

[](#freyr-message-broker)

Inbox and Outbox patterns for Symfony Messenger with transactional guarantees and automatic deduplication.

**This library is in early development. Not production ready.**

Packages
--------

[](#packages)

PackageDescription[freyr/message-broker](https://github.com/freyr/message-broker)Core bundle — outbox publishing, inbox deduplication, serializers[freyr/message-broker-contracts](https://github.com/freyr/message-broker-contracts)Shared interfaces, stamps, and attributes[freyr/message-broker-amqp](https://github.com/freyr/message-broker-amqp)AMQP transport plugin — RabbitMQ publishing, routing, topology managementRequirements
------------

[](#requirements)

- PHP 8.2+
- Symfony 6.4+ or 7.0+
- Doctrine DBAL 3.0+ / ORM 3.0+
- MySQL, MariaDB, or PostgreSQL 13+

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

[](#installation)

```
composer require freyr/message-broker
```

Register the bundle in `config/bundles.php`:

```
return [
    // ...
    Freyr\MessageBroker\FreyrMessageBrokerBundle::class => ['all' => true],
];
```

For AMQP (RabbitMQ) support, also install the transport plugin:

```
composer require freyr/message-broker-amqp
```

```
return [
    // ...
    Freyr\MessageBroker\FreyrMessageBrokerBundle::class => ['all' => true],
    Freyr\MessageBroker\Amqp\FreyrMessageBrokerAmqpBundle::class => ['all' => true],
];
```

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

[](#configuration)

### Bundle Configuration

[](#bundle-configuration)

Create `config/packages/message_broker.yaml`:

```
message_broker:
    inbox:
        message_types:
            # 'order.placed': 'App\Message\OrderPlaced'
            # 'user.registered': 'App\Message\UserRegistered'
```

### Messenger Configuration

[](#messenger-configuration)

Create or update `config/packages/messenger.yaml`:

```
framework:
    messenger:
        failure_transport: failed

        default_middleware:
            enabled: true
            allow_no_handlers: false

        buses:
            messenger.bus.default:
                middleware:
                    - 'Freyr\MessageBroker\Outbox\MessageIdStampMiddleware'
                    - 'Freyr\MessageBroker\Outbox\MessageNameStampMiddleware'
                    - doctrine_transaction
                    - 'Freyr\MessageBroker\Outbox\OutboxPublishingMiddleware'
                    - 'Freyr\MessageBroker\Inbox\DeduplicationMiddleware'

        transports:
            outbox:
                dsn: 'doctrine://default?table_name=messenger_outbox&queue_name=outbox'
                options:
                    auto_setup: true
                retry_strategy:
                    max_retries: 3
                    delay: 1000
                    multiplier: 2

            amqp:
                dsn: '%env(MESSENGER_AMQP_DSN)%'
                serializer: 'Freyr\MessageBroker\Serializer\WireFormatSerializer'
                options:
                    auto_setup: false

            amqp_orders:
                dsn: '%env(MESSENGER_AMQP_DSN)%'
                serializer: 'Freyr\MessageBroker\Serializer\InboxSerializer'
                options:
                    auto_setup: false
                    queues:
                        orders_queue: ~
                retry_strategy:
                    max_retries: 3
                    delay: 1000
                    multiplier: 2

            failed:
                dsn: 'doctrine://default?queue_name=failed'
                options:
                    auto_setup: true

        routing:
            # 'App\Domain\Event\OrderPlaced': outbox
```

### Environment Variables

[](#environment-variables)

Add to `.env`:

```
MESSENGER_AMQP_DSN=amqp://guest:guest@localhost:5672/%2f
```

### Database

[](#database)

The package uses a three-table architecture:

TableManagementPurpose`messenger_outbox`Auto (`auto_setup: true`)Outbox event storage`messenger_messages`Auto (`auto_setup: true`)Failed messages`message_broker_deduplication`Manual migrationInbox deduplication trackingThe `messenger_outbox` and `messenger_messages` tables are created automatically on first worker run. Create a migration for the deduplication table:

```
$this->addSql("
    CREATE TABLE message_broker_deduplication (
        message_id BINARY(16) NOT NULL PRIMARY KEY COMMENT '(DC2Type:id_binary)',
        message_name VARCHAR(255) NOT NULL,
        processed_at DATETIME NOT NULL,
        INDEX idx_dedup_processed_at (processed_at)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
");
```

Run migrations:

```
php bin/console doctrine:migrations:migrate
```

Workers
-------

[](#workers)

```
# Publish outbox events to AMQP
php bin/console messenger:consume outbox -vv

# Consume messages from AMQP
php bin/console messenger:consume amqp_orders -vv
```

Ordered Outbox Delivery
-----------------------

[](#ordered-outbox-delivery)

For per-aggregate causal ordering with multiple outbox workers, use the ordered transport:

```
# config/packages/messenger.yaml
framework:
    messenger:
        transports:
            outbox:
                dsn: 'ordered-doctrine://default?table_name=messenger_outbox&queue_name=outbox'
                options:
                    auto_setup: true
```

Add `PartitionKeyStampMiddleware` to your bus middleware and dispatch with a partition key:

```
use Freyr\MessageBroker\Contracts\PartitionKeyStamp;

$this->bus->dispatch($orderPlaced, [
    new PartitionKeyStamp((string) $orderPlaced->orderId),
]);
```

Events with the same partition key are delivered to AMQP in insertion order. Events with different partition keys are processed in parallel across workers.

See [Ordered Delivery](docs/ordered-delivery.md) for the full guide.

Documentation
-------------

[](#documentation)

- [Database Schema](docs/database-schema.md) — table architecture, migrations, and cleanup strategies
- [Outbox Pattern](docs/outbox-pattern.md) — transactional event publishing
- [Ordered Delivery](docs/ordered-delivery.md) — per-aggregate causal ordering with partition keys
- [Inbox Deduplication](docs/inbox-deduplication.md) — preventing duplicate message processing
- [Message Serialization](docs/message-serialization.md) — semantic naming and cross-language compatibility

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance84

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community8

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 ~29 days

Recently: every ~36 days

Total

6

Last Release

62d ago

PHP version history (2 changes)v0.2.0PHP &gt;=8.4

v0.3.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/089ad642f79ded10ae84d86db9f2a71b74c88e02fdd3b57af9643951d41420d4?d=identicon)[Freyr](/maintainers/Freyr)

---

Top Contributors

[![freyr](https://avatars.githubusercontent.com/u/800286?v=4)](https://github.com/freyr "freyr (109 commits)")

---

Tags

symfonyevent-drivenulidMessengeroutbox-patterndeduplicationinbox-pattern

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/freyr-message-broker/health.svg)

```
[![Health](https://phpackages.com/badges/freyr-message-broker/health.svg)](https://phpackages.com/packages/freyr-message-broker)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M646](/packages/sylius-sylius)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[open-dxp/opendxp

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

7310.3k29](/packages/open-dxp-opendxp)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M385](/packages/shopware-core)

PHPackages © 2026

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