This package provides a simple way to publish and consume messages from RabbitMQ.
composer require alterindonesia/rabbit-mq
Add the following to your .env file:
RABBITMQ_HOST=
RABBITMQ_PORT=
RABBITMQ_USER=
RABBITMQ_PASSWORD=
RABBITMQ_VHOST=
RABBITMQ_EXCHANGE=
$rabbit = new Alterindonesia\RabbitMQ\Services\RabbitMQPublisherService();
$rabbit->test();
it will send to exchange name test
with routing key test
and message test
$rabbit = new Alterindonesia\RabbitMQ\Services\RabbitMQPublisherService();
$rabbit->publish(
['test'=>'test'],
'exchange_name',
'routing_key'
);
$listener = new Alterindonesia\RabbitMQ\Services\RabbitMQConsumerService();
$listener->listen('queue_name');
or with command
php artisan alter:mq-consume {--routing=} {--exchange=} {--queue=}
This package is open-sourced software licensed under the MIT license.