PHPackages                             magium/messaging - 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. magium/messaging

ActiveLibrary

magium/messaging
================

Interfaces for use with a generic messaging platform

0.1.2(9y ago)0161Apache-2.0PHP

Since Mar 1Pushed 9y ago1 watchersCompare

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

READMEChangelog (3)DependenciesVersions (5)Used By (0)

Currently just an experiment in messaging
=========================================

[](#currently-just-an-experiment-in-messaging)

This library consists only of interfaces. There is no functionality in it. It is intended to be used as a means of allowing PHP developers to build messaging-based applications without committing to a specific messaging platform. The platform libraries would need to implement the actual implementation. The **only** purpose of this library is to define consistent usage across libraries.

This borrows **very** heavily from the JMS standard, though is much smaller.

How would you use this?

As a consumer
-------------

[](#as-a-consumer)

```
class DoSomeConsuming implements \Magium\Messaging\ExceptionListenerInterface
{

    protected $connectionFactory;

    public function __construct(
        \Magium\Messaging\ConnectionFactoryInterface $factory
    )
    {
        $this->connectionFactory = $factory;
    }

    public function onException(\Magium\Messaging\MessagingException $e)
    {
        echo 'Oh well ¯\_(ツ)_/¯ : ' . $e->getMessage();
        die();
    }

    public function run()
    {
        $connection = $this->connectionFactory->createConnection();
        $connection->setExceptionListener($this);

        $session = $connection->createSession();
        $destination = $session->createQueue('some queue');

        $consumer = $session->createConsumer($destination);

        $message = $consumer->receive();

        echo $message->getText();
    }

}

```

When you create an instance of this class you would need to provide your messaging library's factory. From there on out it should work exactly the same.

As a producer
-------------

[](#as-a-producer)

```
