kontoulis/rabbitmq-laravel
Larablocks Analysis
kontoulis/rabbitmq-laravel works with Laravel 5 (latest release 2.1.10, Jan 3, 2018), which reached end of life: no more fixes, even for security.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 5, past end of life
- No release in the last 12 months (last: Jan 3, 2018)
- 4 downloads a month (needs 10,000)
- 15 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Jan 3, 2018.
- No releases in the last 12 months.
- First released: Oct 3, 2015.
- Monthly downloads: 4.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.
| Install | |
|---|---|
composer require kontoulis/rabbitmq-laravel |
|
| Latest Version: | 2.1.10 |
| PHP: | >=5.3.0 |
| Laravel: | 5 |
| License: | MIT |
| Last Updated: | Feb 3, 2018 |
| Links: | GitHub · Packagist |
RabbitMQLaravel
Installation
Via Composer
$ composer require kontoulis/rabbitmq-laravel
Add the Service Provider to config/app.php
Kontoulis\RabbitMQLaravel\RabbitMQLaravelServiceProvider::class,
Add the RabbitMQ facade to config/app.php
'RabbitMQ' => Kontoulis\RabbitMQLaravel\Facades\RabbitMQ::class,
Publish the configuration file and edit it if needed in config/rabbitmq-laravel.php
$ php artisan vendor:publish
Usage
- Routing Key / Queue Name
The default routing key can be set in config file, or env("APP_NAME")."_queue") will be used.
Also most methods take argument $routingKey which can override the default.
RabbitMQ::setRoutingKey("myRoutingKey/queueName");
- Exchange
If you don't set an exchange the default '' exchange will be used.
If you set one, make sure the bindings are set in RabbitMQ system.
if you are not familiar with exchanges you will probably do not need to set that.
RabbitMQ::setExchange("myExchange")'
You can use the RabbitMQ facade to do anything as seen in https://github.com/php-amqplib/php-amqplib/blob/master/PhpAmqpLib/Channel/AMQPChannel.php . Basically, the RabbitMQ facade uses the Broker class which is an extension of AMQPChannel.
- Publishing
// Single message
$msg = [
"key1" => "value1",
"key2" => "value2"
];
RabbitMQ::publishMesssage($msg);
// OR
RabbitMQ::publishMessage($msg, "myRoutingKey");
// Batch publishing
$messages = [
[ "messsage_1_key1" => "value1",
"messsage_1_key2" => "value2"
],
[
"messsage_2_key1" => "value1",
"messsage_2_key2" => "value2"
]
];
RabbitMQ::publishBatch($messages);
// OR
RabbitMQ::publishBatch($messages, "myRoutingKey");
- Consuming the Queue
In order to consume the queue, you could either use the AmqpChannel through the Facade, or use a better to manage approach with QueueHandlers. A QueueHandler should extend the Kontoulis\RabbitMQLaravel\Handlers\Handler class and the built-in ListenToQueue method accepts an array of handlers to process the queue message. If more than one handler exists in array, there are some Handler return values that will use the follow up QueueHandlers in cases of failure of the previous. There is also a Kontoulis\RabbitMQLaravel\Handlers\Handler\DefaultHandler class as example and/or debug handler.
namespace Kontoulis\RabbitMQLaravel\Handlers;
use Kontoulis\RabbitMQLaravel\Message\Message;
/**
* Class DefaultHandler
* @package Kontoulis\RabbitMQLaravel\Handlers
*/
class DefaultHandler extends Handler{
/**
* Tries to process the incoming message.
* @param Message $msg
* @return int One of the possible return values defined as Handler
* constants.
*/
public function process(Message $msg)
{
return $this->handleSuccess($msg);
}
/**
* @param $msg
* @return int
*/
protected function handleSuccess($msg)
{
var_dump($msg);
/**
* For more Handler return values see the parent class
*/
return Handler::RV_SUCCEED_STOP;
}
}
In order to Listen to the Queue you have to pass an array of Handlers to the method
$handlers = ["\\App\\QueueHandlers\\MyHandler"];
\RabbitMQ::listenToQueue($handlers);
License
The MIT License (MIT). Please see LICENCE.md for more information.
Related Packages
Send messages with resilience and idempotence between different applications usi...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 2.1.10 | >=5.3.0 | ~5.1 | MIT | |
| 2.1.1 | >=5.3.0 | ~5.1 | MIT | |
| v2.0.11 | >=5.3.0 | ~5.1 | MIT | |
| v2.0.1 | >=5.3.0 | MIT | ||
| v2.0.0 | >=5.3.0 | MIT | ||
| v1.0.4 | >=5.3.0 | ~5.1 | MIT | |
| v1.0.0 | >=5.3.0 | ~5.1 | MIT |