Download the PHP package kakaprodo/laravel-message-broker without Composer
On this page you can find all versions of the php package kakaprodo/laravel-message-broker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kakaprodo/laravel-message-broker
More information about kakaprodo/laravel-message-broker
Files in kakaprodo/laravel-message-broker
Package laravel-message-broker
Short Description A RabbitMQ message broker for Laravel that provides clean routing, similar to Laravel's route system, for sending and consuming messages.
License MIT
Informations about the package laravel-message-broker
Laravel Message Brokers
A RabbitMQ message broker for Laravel that provides clean routing, similar to Laravel's route system, for sending and consuming messages.
Prerequisites
Before installing, ensure your project meets the following requirements:
We assume that you have RabbitMQ installed on your computer.
Installation
Run the following Composer command:
Setup
1. Publish Package Files
Before using the package, publish its configuration and route files:
This will publish:
config/message-broker.phproutes/message-broker.php
2. Configure Environment Variables
Add the following RabbitMQ connection settings to your .env file:
Usage
Sending Messages
You can send messages to a specific subscriber or broadcast to multiple subscribers.
Send Direct Message
Use the sendTo method to send a message to a specific subscriber by providing the exchange_name, payload_message, and routing_key.
Broadcast Message
Use the broadcast method to send a message to all subscribers of an exchange.
Subscribing to Exchanges
You can subscribe to fanout (broadcast), direct, and topic messages. Define routes in routes/message-broker.php.
Broadcasted Messages
Subscribe to broadcast messages using any:
Direct Messages
Subscribe to a direct message by specifying the exchange_name and routing_key:
Subscribe to multiple routing keys:
Topic Messages
Subscribe to topic messages by specifying the topic exchange and routing key:
Message Handlers
The package supports three types of handlers:
-
Closure Handler
-
PHP Action Classes
The class should have a
handlemethod: - Custom Data Action Classes (
kakaprodo/custom-data)
Consuming Messages
After defining your subscription routes, you can start processing published messages using the following Artisan command:
If there are any messages that are stuck and you want to acknowledge them so they are not repeatedly pulled, use the --ack flag:
All versions of laravel-message-broker with dependencies
laravel/framework Version >=8.0
kakaprodo/custom-data Version >=2.3.3 || dev-develop
php-amqplib/php-amqplib Version ^3.7