colearn/rabbitmq

Follow guide https://www.rabbitmq.com/ to create a library easy to use. For Laravel!

1.0.3 2021-10-25 09:52 UTC

This package is auto-updated.

Last update: 2024-04-25 15:50:02 UTC


README

Installation

Install via composer

composer require colearn/rabbitmq

Publish package assets

php artisan vendor:publish --provider="CoLearn\RabbitMQ\RabbitMQServiceProvider"

Security

If you discover any security related issues, please email instead of using the issue tracker.

How to use

####Server RPC as service

$this->rabbit = app('rabbitmq.queue')->connection('rabbitmq');
RabbitMQ::declareRPCServer($this->rabbit, 'name_of_queue', function ($request) {
    # code...
});

####Client RPC as service

$this->rabbit = app('rabbitmq.queue')->connection('rabbitmq');
$stringInput = json_encode(array);
$response = RabbitMQ::declareRPCClient($this->rabbit, 'name_of_queue', $stringInput);

####Server Worker Queue service

$this->rabbit = app('rabbitmq.queue')->connection('rabbitmq');
RabbitMQ::declareWorkerQueueServer($this->rabbit, 'name_of_queue', function ($request) {
    RabbitMQ::declareAck($request);
});