Laravel Sqs Fifo Queue
Laravel Sqs Fifo Queue stats
- Downloads
- 2.2M
- Stars
- 137
- Open Issues
- 1
- Forks
- 58
Adds a Laravel queue driver for Amazon SQS FIFO queues.
Summary of Laravel SQS FIFO Queue Package
The laravel-sqs-fifo-queue package provides a specialized queue driver for handling Amazon SQS FIFO (First In, First Out) queues within Laravel and Lumen applications. Unlike standard SQS queues, FIFO queues ensure that messages are processed exactly once and in the order they are sent. This package seamlessly integrates these queues into the Laravel framework, which natively supports only standard SQS queues.
Key Features
- SQS FIFO Support: Enables the use of SQS FIFO queues, which are not natively supported by Laravel.
- Message Grouping: Supports multiple message groups within a single FIFO queue to optimize performance and order.
- Deduplication Configuration: Offers configurable deduplication strategies (
unique,content, or relying on SQS's built-in capabilities). - Environment Specific Suffix: Allows dynamic queue naming based on the environment, aiding simpler configuration across development, staging, and production.
- Transaction-aware Dispatching: Option to delay job dispatch until after database transactions commit, ensuring data consistency.
- Integration with Laravel Job Batching: Ensures FIFO queue compatibility with Laravel's job batching features.
Installation and Configuration
Install via Composer:
composer require shiftonelabs/laravel-sqs-fifo-queue
For Laravel, no additional service provider registration is needed due to package auto-discovery. For Lumen, manual registration is required in bootstrap/app.php.
Configuration involves setting up the queue.php config file with appropriate credentials and queue details:
'sqs-fifo' => [ 'driver' => 'sqs-fifo', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'prefix' => env('SQS_FIFO_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'queue' => env('SQS_FIFO_QUEUE', 'default.fifo'), 'suffix' => env('SQS_FIFO_SUFFIX'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'group' => 'default', 'deduplicator' => env('SQS_FIFO_DEDUPLICATOR', 'unique'), 'allow_delay' => env('SQS_FIFO_ALLOW_DELAY', false),],
Usage
Utilize the FIFO queue just like any standard Laravel queue. The package handles specifics such as message grouping and deduplication internally. Jobs can be dispatched to different message groups or use different deduplication strategies by using provided methods like onMessageGroup() and withDeduplicator().
Advanced Configuration
The package allows for advanced customization including per-job group settings, custom deduplication logic, and handling of delayed jobs in a FIFO context (note that FIFO supports only queue-wide delay settings).
Conclusion
The laravel-sqs-fifo-queue package is an essential tool for developers needing reliable and ordered processing of jobs in a Laravel application, leveraging the advanced features of Amazon SQS FIFO queues. It simplifies integration and usage while providing powerful options for performance tuning and customization.
Shift One Labs is a web application development company specializing in both customizing existing applications and developing new ones.