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 connectionSimpleMQ::queue('xp') ->setBody(['name' => '10 accepted answers', 'points' => 500]) ->handler('award-xp') ->publish(); // Multiple connection supportSimpleMQ::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.