Laravel Packages

Laravel Simple RabbitMQ Package

Published
Laravel Simple RabbitMQ Package image

The Simple RabbitMQ package for Laravel makes it simple to use RabbitMQ with support for multiple connections, easy publishing, and consumer mode. If you are already familiar with RabbitMQ, this package lets you easily configure multiple queues and exchange connections via Laravel's service container:

// Default connection
SimpleMQ::queue('xp')
->setBody(['name' => '10 accepted answers', 'points' => 500])
->handler('award-xp')
->publish();
 
// Multiple connection support
SimpleMQ::connection('awards')
->queue('xp')
->setBody(['name' => '10 accepted answers', 'points' => 500])
->handler('award-xp')
->publish();

On the consumer end, here's an example of how you can register a handler to process a queue:

use App\AMQP\Handlers\AwardXPHandler;
use Usmonaliyev\SimpleRabbit\Facades\ActionMQ;
use Usmonaliyev\SimpleRabbit\MQ\Message;
 
class AwardXPHandler
{
public function handle(Message $message)
{
// do something...
 
$message->ack();
 
return ['ok' => true];
}
}
 
// Elsewhere, register a handler:
ActionMQ::register('award-xp', [AwardXPHandler::class, 'handle']);

Main Features

  • Multiple Connections: Effortlessly manage multiple RabbitMQ connections within the same application.
  • Exchange supporting: You can push messages to exchanges
  • Message Publishing: Easily publish messages to queues and exchange with a fluent, chainable syntax.
  • Consumer Mode: Enable consumers to receive and process messages from queues in real time.
  • Manage queues and exchanges in config file: You can register queues and exchanges in config/simple-mq.php and define them in easy way which is amqp:define-queues command.

The Simple RabbitMQ Laravel package uses php-amqplib as the RabbitMQ client—a pure PHP implementation of the AMQP protocol. If you've never used RabbitMQ, I recommend the RabbitMQ Tutorials and the RabbitMQ Documentation.

Get started with the Simple RabbitMQ Laravel package by viewing the README and source code on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article