Download the PHP package xerxes/laravel-rabbitmq-communication without Composer
On this page you can find all versions of the php package xerxes/laravel-rabbitmq-communication. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xerxes/laravel-rabbitmq-communication
More information about xerxes/laravel-rabbitmq-communication
Files in xerxes/laravel-rabbitmq-communication
Package laravel-rabbitmq-communication
Short Description A Laravel package for RabbitMQ messaging with outbox pattern, dead letter queues, and automatic retry mechanisms
License MIT
Informations about the package laravel-rabbitmq-communication
Laravel RabbitMQ Communication
A Laravel package for RabbitMQ messaging with support for the outbox pattern, event consumers, dead letter queues, and automatic retry mechanisms.
Features
- Direct Publish with Outbox Fallback - Messages are published directly; if RabbitMQ is unavailable, they're stored for later retry
- Event Consumers - Consume messages from multiple queues with configurable handlers
- Dead Letter Queue (DLQ) - Automatic retry with exponential backoff, failed messages go to DLQ
- Type-Safe Enums - PHP 8.1+ enums for status and mode handling
- Fully Configurable - Environment-based configuration for all settings
Requirements
- PHP 8.1+
- Laravel 9, 10, 11, or 12
- RabbitMQ Server
- ext-json
Installation
Publish the configuration:
Run migrations:
Configuration
Environment Variables
Publishing Messages
Basic Publishing
Publishing with Headers
Outbox Pattern (Guaranteed Delivery)
The outbox pattern is always enabled as an automatic fallback and cannot be disabled. Messages follow this flow:
- Try direct publish - Message is sent immediately to RabbitMQ
- On failure - Message is automatically stored in the database outbox table
- Outbox worker - Processes pending messages and retries publishing
Process outbox messages:
Using Laravel Events
Implement the ShouldPublish interface to automatically publish events:
Consuming Messages
Configuration
Define event consumers in config/rabbitmq.php:
Handler Class
Your handler should implement the MessageHandler interface:
Running the Consumer
Consumer Modes
Configure how consumed events are dispatched:
- sync: Events fired synchronously. Errors stop the consumer (unless DLQ is enabled).
- kind-sync: Events fired synchronously. Errors are logged but don't stop the consumer.
- job: Events dispatched via Laravel queue jobs.
Message Acknowledgment
Message acknowledgment is always required and cannot be disabled:
- On success: Message is acknowledged and removed from the queue
- On failure: Message is rejected and requeued for retry
- With DLQ enabled: After max retries, message is moved to the dead letter queue
Dead Letter Queue (DLQ)
How It Works
- Message fails processing
- Republished to retry queue with delay
- After TTL, routed back to original queue
- After max retries (default: 3), moved to dead letter queue
- Failed messages can be manually reprocessed
Retry Flow
Reprocessing Failed Messages
Available Commands
| Command | Description |
|---|---|
rabbitmq:consume-events |
Start consuming messages from configured queues |
outbox:work |
Run outbox worker (continuous) |
outbox:process |
Process outbox messages once |
rabbitmq:declare-exchanges |
Declare configured exchanges |
rabbitmq:test-connection |
Test RabbitMQ connection |
rabbitmq:reprocess-dlq {queue} |
Reprocess messages from dead letter queue |
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-rabbitmq-communication with dependencies
illuminate/contracts Version ^9|^10|^11|^12
php-amqplib/php-amqplib Version ^3.0
ext-json Version *