PHPackages                             everlution/message-bus - 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. everlution/message-bus

ActiveLibrary

everlution/message-bus
======================

MessageBus

v1.1.1(6y ago)0431[4 issues](https://github.com/everlution/message-bus/issues)PHPPHP &gt;=7

Since May 26Pushed 6y ago3 watchersCompare

[ Source](https://github.com/everlution/message-bus)[ Packagist](https://packagist.org/packages/everlution/message-bus)[ RSS](/packages/everlution-message-bus/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Everlution PHP MessageBus
=========================

[](#everlution-php-messagebus)

This library provides an eventbus solution in PHP for making microservices interact together.

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

[](#installation)

As usual just use composer as follows

```
composer require everlution\message-bus

```

Components
----------

[](#components)

This library provides default components but you can easily develop your owns by implementing the proper interfaces.

### Transport

[](#transport)

Must implement `Everlution\MessageBus\Transport\TransportInterface`.

This component is the actual service that interacts with the "physical" message bus. In other words it is the implementation for using a specific technology.

This library provides already a transport for RabbitMQ `Everlution\MessageBus\Transport\RabbitMqTransport` using a fanout exchange and re-publishing the message in case of any exception thrown within your consumer.

```
use PhpAmqpLib\Connection\AMQPStreamConnection;
use Everlution\MessageBus\Transport\RabbitMqTransport;

$connection = new AMQPStreamConnection('rabbitmq_host', 5672, 'user', 'password');
$exchange = 'MessageBus';
$consumerName = 'consumer1';

$transport = new RabbitMqTransport($connection, $exchange, $consumerName);
```

### Message Definition

[](#message-definition)

This is the actual message that will be published on the Transport.

A message can only be an array that will be validated using a JSON Schema definition. In fact the message definition requires you to provide:

- the name of the message (as a discriminator)
- the JSON Schema that validates the message payload itself

The library provides the `Everlution\MessageBus\MessageDefinition\PingMessageDefinition` for testing purposes.

```
