Download the PHP package sobirjonovs/laravel-rabbit without Composer
On this page you can find all versions of the php package sobirjonovs/laravel-rabbit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sobirjonovs/laravel-rabbit
More information about sobirjonovs/laravel-rabbit
Files in sobirjonovs/laravel-rabbit
Package laravel-rabbit
Short Description Easy tool for working with RabbitMQ
License MIT
Homepage https://github.com/sobirjonovs/laravel-rabbit
Informations about the package laravel-rabbit
Installation
After installing the package, publish its assets using the rabbit:install
Artisan command.
Settings
config/amqp.php
- RabbitMQ settingsconfig/rabbit_events.php
- Write methods what they are responsible for the events dispatched from another microserviceapp/Providers/RabbitServicePRovider
- Write queues what to be declared at runtime
Examples
1. Consuming messages
2. Publishing message
3. Publishing and consuming a message at once
Development
You can register your events in config/rabbit_events.php
like that
Now you need a new service and DTO (Data Transfer Object) classes.
To create a new service class with a function, use the following command:
This will create a new service class named ProductService
with a function named createProduct
.
It also creates DTO class which will accepted in createProduct
function.
The generated files will be located in the following directories:
- Service class: App/Services/ProductService.php
- Data Transfer Object (DTO): App/Services/Dto/ProductServiceObject.php
If you want to change namespace of service and DTO classes, you can replace them in config/amqp.php
.
Additional
While application is accepting message, if exception is happened.
The message will be sent to dead-letter-queue
which is config('amqp.dead_letter_queue')
.
The message may not pass from validation, in it the message will be sent to invalid-queue-letter
which is config('amqp.invalid_letter_queue')
.
If you don't define invalid_letter_queue
in your 'config/amqp.php' file. The message will be deleted.
Note that: The both options only work in publisher and subscriber mode.
Queues
You need to configure your queues in config/amqp.php
.