A wrapper for vladimir-yuldashev RabbitMQ Queue for Laravel with Actions

Overview

RabbitMQ Actions

This package its a wrapper of vladimir-yuldashev/rabbitmq-queue-laravel.

Adds a new feature to produce and consume messages with RabbitMQ/AMQP protocol.

Versão em PT-BR

Install and Requirements


Requirements:

  • PHP 8.0 +
  • Laravel 8.0 +
  • RabbitMQ driver for Laravel Queue 12.0+

Install this package with composer:

composer require rocketslab/rabbitmq-actions

Configure RabbitMQ driver for Laravel Queue


Follow vladimir-yuldashev/rabbitmq-queue-laravel installation.

How to configure in RLQ documentation yuldashev/rabbitmq-queue-laravel.

Publish the configuration


php artisan vendor:publish --provider=RocketsLab\\RabbitMQActions\\RabbitMQActionsServiceProvider

The default action namespace its App\RabbitMQ\Actions saving actions at app/RabbitMQ/Actions folder. You can change this setting the namespace config. For example:

config/rabbitmq-actions.php

    ...
    'namespace' => 'MyDomain\\Actions'
    ...

When creating new actions, this actions are save at app/MyDomain/Actions directory and your actions namespace its changed to App\MyDomain\Actions.

Creating Actions


The motivation for creating this package is to find a way to simplify sending and receiving messages through RabbitMQ. One of the ways I found for this was to use actions to define what type of message is being sent from the producer to be treated as an action by the consumer.

To create an action use the artisan make:rmq-action command.

php artisan make:rmq-action MyAction

The action file looks like this:

namespace App\RabbitMQ\Actions;

use RocketsLab\RabbitMQActions\Contracts\Action;

class MyAction implements Action
{
    /**
     * Handles the message data
     *
     * @param mixed $data
     *
     */
    public function handle(mixed $data)
    {
        // Process the message data from broker
    }
}

The message data content its passed at the Action handle method.

Actions are automatically registered into the Laravel container. This behavior launches the action as soon as the message is received by the consumer.

Producing Messages


Installing this package and configuring the application to send messages as a producer is simple. This package class ProducerMessage have a single method called send that takes three parameters: $action, $data and an optional $queue.

The action parameter is the name of action, that translates the name of an action in consumer application.

The data parameter is the content data to be send to consumer.

The queue parameter is the name of queue. Default is Laravel queue default.

Eg: ProduceMessage::send('my-action', 'hello'), the my-action its the MyAction class registered automatically by consumer.

Custom actions


The default actions name its the name of action Class in kebab form.

But sometimes you want to have more control over the name of actions. To customize the actions "keys", register this in custom_actions option at config file.

config/rabbitmq-actions.php

    ...
    'custom_actions' => [
        'hello-action' => MyAction::class
    ];
    ...

in the producer application:

    ProducerMessage::send('hello-action', 'world!');

in the consumer application:

    MyAction handle method its called

At moment, once this option is used, the automatic registration its disabled, and you have to register all actions here.

Roadmap


This is a work in progress project. In the future more features can be created.


Thank you!

Don`t forget to leave a star here if I help in any way ;)

Jorge <@jjsquady> Gonçalves

You might also like...
Laravel wrapper package for the Aimon.it API

Laravel Aimon Package A laravel wrapper package for the Aimon.it API. For more information see Aimon Requirements Laravel 6 or later Installation Inst

PayuMoney Gateway wrapper for Laravel.
PayuMoney Gateway wrapper for Laravel.

PayuMoney Integration with Laravel Easy to use integration for PayUMoney into Laravel apps. Video Tutorial Usage composer require infyomlabs/laravel-p

A Laravel wrapper for spatie/dns. Allows to query and validate DNS records.

A Laravel wrapper for spatie/dns. Allows to query and validate DNS records.

Laravel API wrapper to interact fluently with your Janus Media Server

Laravel API wrapper to interact fluently with your Janus Media Server. Core server interactions, as well as the video room plugin included.

A laravel wrapper for BnpParibas Mercanet payment gateway
A laravel wrapper for BnpParibas Mercanet payment gateway

Laravel Mercanet A laravel wrapper for BnpParibas Mercanet which provide a lightweight public api to process your online payments from your laravel ap

Open Food Facts API wrapper for Laravel

Laravel Open Food Facts API This package provides a convenient wrapper to the Open Food Facts API for Laravel applications (5.7+). Installation You ca

a Google API v3 wrapper for Laravel 4.x

A Google API v3 wrapper for Laravel 4 This package enables a Laravel flavoured way to manage Google services through its API interface (v3) Installati

27Laracurl Laravel wrapper package for PHP cURL class that provides OOP interface to cURL. [10/27/2015] View Details

Laracurl Laravel cURL Wrapper for Andreas Lutro's OOP cURL Class Installation To install the package, simply add the following to your Laravel install

Laravel wrapper for Sentry Official API

Laravel Sentry API Provides a simple laravel wrapper to some of the endpoints listed on (Official Sentry API)[https://docs.sentry.io/api/]. **Note: Th

Owner
RocketsLab
RocketsLab
Apply rate limiters to Laravel Livewire actions.

This package allows you to apply rate limiters to Laravel Livewire actions. This is useful for throttling login attempts and other brute force attacks

Dan Harrin 207 Dec 30, 2022
Ghygen is a GitHub Actions configurator for your PHP / Laravel project.

Ghygen Ghygen is a GitHub actions Yaml Generator. Ghygen allows you creating your Yaml file for GitHub Actions, for Laravel/PHP web application, so yo

Hi Folks! 268 Dec 11, 2022
Log user authentication actions in Laravel.

Laravel Auth Log The laravel-auth-log package will log all the default Laravel authentication events (Login, Attempting, Lockout, etc.) to your databa

Label84 29 Dec 8, 2022
A laravel package for cascding SoftDeletes delete/restore actions

This is a Laravel 8 package for cascding SoftDeletes delete/restore actions. Laravel 7.0 is supported since v0.1.0 Laravel 8.0 is supported since v0.1

Razi Alsayyed 9 Mar 20, 2022
webtrees module: enhanced clippings cart with more functions to add records to the clippings cart and to start actions on these records

webtrees module hh_clippings_cart_enhanced !!! This is an alpha version! Do not use it in a productive webtrees system! !!! This webtrees custom modul

Hermann Hartenthaler 1 Sep 18, 2022
Make any class queue aware in a Laravel app

Make any class queue aware This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. Support us We in

Spatie 8 Jun 17, 2022
A Laravel package to monitor the status and history of jobs on the queue.

Monitored Jobs for Laravel Overview This package tracks the status and history of your queued jobs by hooking into the events that Laravel fires for i

Aryeo 9 Dec 9, 2022
Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite

Mollie for Laravel Laravel-Mollie incorporates the Mollie API and Mollie Connect into your Laravel or Lumen project. Accepting iDEAL, Apple Pay, Banco

Mollie 289 Nov 24, 2022
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 2 Feb 16, 2022
A CommonMark wrapper for Laravel

Laravel Markdown Laravel Markdown was created by, and is maintained by Graham Campbell, and is a CommonMark wrapper for Laravel. It ships with integra

Graham Campbell 1.2k Jan 2, 2023