PHPackages                             it-bens/message-bus-redirect-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. [Queues &amp; Workers](/categories/queues)
4. /
5. it-bens/message-bus-redirect-bundle

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

it-bens/message-bus-redirect-bundle
===================================

Bundle that allows redirect a messenge from one message bus to another.

v0.1.0(3y ago)3141MITPHPPHP &gt;=8.0

Since Aug 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/it-bens/message-bus-redirect-bundle)[ Packagist](https://packagist.org/packages/it-bens/message-bus-redirect-bundle)[ RSS](/packages/it-bens-message-bus-redirect-bundle/feed)WikiDiscussions master Synced 1mo ago

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

The Message Bus Redirect Bundle
===============================

[](#the-message-bus-redirect-bundle)

There are some bundles that cannot handle multiple buses in one application. That can be a problem if commands or queries should be passed to different buses. This bundle can redirect envelops of the Symfony messenger from one bus to another by using a middleware.

How to install the bundle?
--------------------------

[](#how-to-install-the-bundle)

The package can be installed via Composer:

```
composer require it-bens/message-bus-redirect-bundle
```

If you're using Symfony Flex, the bundle will be automatically enabled. For older apps, enable it in your Kernel class.

How does the redirection process work?
--------------------------------------

[](#how-does-the-redirection-process-work)

Redirecting an envelope from one bus to another is quite simple with a middleware. It has to catch the envelope from the current bus and dispatch it into the target bus. Currently, the middleware does not pass the envelope to the next middleware. That means that the envelope will not be processed on the source bus. (this behavior may change or become configurable)

### How does the bundle know what the target bus is?

[](#how-does-the-bundle-know-what-the-target-bus-is)

The target bus is determined by redirect strategies. That are services that implement the `RedirectStrategyInterface`. They receive the envelope and return the name of the bus it should be passed to.

Currently, two strategies are implemented: the `MessageClassStrategy` and the `DecisionMakerStrategy`. The first one uses a Message-Class-to-Bus-Name map from the bundle configuration (described later) to find the bus name by the class of the message. The second one is more flexible. It allows the creation of decision maker services, that implement the `DecisionMakerInterface`. This strategy passes the responsibility for the logic to the person, who uses this bundle.

> ⚠ Multiple strategies can be used in a configured order. The middleware will use the first non-null bus name that is returned from a strategy.

> ⚠ The `DecisionMakerStrategy` calls the decision makers in no particular order. So, the decision makers should always return `null` if they should be not responsible.

How to configure this bundle?
-----------------------------

[](#how-to-configure-this-bundle)

The following configuration uses the `MessageClassStrategy` and the `DecisionMakerStrategy`.

```
itb_message_bus_redirect:
  redirect_strategies:
    - ITB\MessageBusRedirectBundle\RedirectStrategies\MessageClassStrategy
    - ITB\MessageBusRedirectBundle\RedirectStrategies\DecisionMakerStrategy
```

Any unknown strategy will result in a configuration error.

The `MessageClassStrategy` requires additional configuration to work:

```
  message_classes:
    - { message_class: SomeNamespace\CreateObjectCommand, bus_name: command.bus }
    - { message_class: SomeNamespace\QueryObjectsCommand, bus_name: query.bus }
```

The message classes have to be fully qualified class names. The bus names have to match the ones from the messenger configuration.

The `DecisionMakerStrategy` requires no additional configuration but at least one registered decision maker.

How to enable the middleware?
-----------------------------

[](#how-to-enable-the-middleware)

The middleware will only be used if a bus is configured to do so:

```
framework:
    messenger:
        default_bus: default.bus
        buses:
            default.bus:
                default_middleware: false
                middleware:
                    - ITB\MessageBusRedirectBundle\MessageRedirectMiddleware
                    - add_bus_name_stamp_middleware
                    - reject_redelivered_message_middleware
                    - dispatch_after_current_bus
                    - failed_message_processing_middleware
                    - send_message
```

The Symfony messenger allows no explicit middleware order. In general the `MessageRedirectMiddleware` can be used in any position and will work just fine (if no other middleware interferes). But it makes more sense to place it on one of the first positions to avoid unnecessary processing. If the configured bus should only be used for redirection, the `MessageRedirectMiddleware` should be the only middleware. If other middleware should be called they have to be put first by their service name. (this example uses the default middlewares normally configured by Symfony but without the `HandleMessageMiddleware`)

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

[](#contributing)

I am really happy that the software developer community loves Open Source, like I do! ♥

That's why I appreciate every issue that is opened (preferably constructive) and every pull request that provides other or even better code to this package.

You are all breathtaking!

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

1359d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/94aa1cc7aa38ca9d3f6bb96541ff813027df1f0cf478b3c53c41385876503b2c?d=identicon)[SpiGAndromeda](/maintainers/SpiGAndromeda)

---

Top Contributors

[![SpiGAndromeda](https://avatars.githubusercontent.com/u/15141351?v=4)](https://github.com/SpiGAndromeda "SpiGAndromeda (8 commits)")

---

Tags

api-platformmessengermiddlewaresymfony-bundle

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/it-bens-message-bus-redirect-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/it-bens-message-bus-redirect-bundle/health.svg)](https://phpackages.com/packages/it-bens-message-bus-redirect-bundle)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M647](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

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

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

1.3k1.3M152](/packages/sulu-sulu)[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)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[shopware/storefront

Storefront for Shopware

684.2M148](/packages/shopware-storefront)

PHPackages © 2026

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