trego/broker

A message broker package for hypedeals

1.0.1 2018-12-01 05:58 UTC

This package is auto-updated.

Last update: 2025-01-29 06:01:57 UTC


README

A message broker for HypeDeals using AMQPLibrary.

Installation

To perform package installation, type a following syntax in your terminal.

php composer require trego/broker

Then copy arrays inside trego/broker/amqp.php inside vendor directory to config directory in main directory. Adjust config file base on your configuration.

Post Installation

After completed an installation, add the following syntax in Register Service Provider section at bootstrap/app.php file.

$app->register(Trego\Broker\BrokerServiceProvider::class)

Then added the following syntax to configure a config file at bootstrap/app.php file.

// $app->withFacades(); 

// $app->withEloquent();

$app->configure('amqp');

How to use

After perform such installation, you are now able to Publish and Consume a message.

To publish a message

use Trego\Broker\Facades\Broker;

Broker::publish('message', 'routing-key')

To consume a message

use Trego\Broker\Facades\Broker;

Broker::consume('queue-name', 'routing-key', function ($message, $consumer) {
    var_dump($message->body);
    $consumer->acknowledge($message);
});