ankurk91/laravel-dedupe-queue

Prevent duplicate jobs from running in Laravel php framework

1.0.0 2023-02-24 09:08 UTC

This package is auto-updated.

Last update: 2024-04-24 13:16:05 UTC


README

Packagist GitHub-tag License Downloads GH-Actions codecov

Prevent duplicate jobs in Laravel php framework.

Warning This package is in its early stage and may have some edge case left.

Why and How?

Laravel does not prevent duplicate jobs in AWS SQS Standard Queue.

This package takes advantage of the UUID assigned to each of the job pushed to the queue. The UUID of the job does not get changed if the same message appears again in SQS queue.

This package injects a global middleware to all Jobs, Mailables, Notifications and Listeners; which keep tracks of incoming jobs and discards any duplicates by checking the UUID.

Installation

You can install the package via composer:

composer require "ankurk91/laravel-dedupe-queue"

The service provider will automatically register itself.

Optionally, You can publish the config file by:

php artisan vendor:publish --provider="Ankurk91\DedupeQueue\DedupeQueueServiceProvider"

Note It is suggested to use Redis, Memcached or DynamoDB for faster Atomic Locks.

Usage

Install and forget it.

You can keep this package enabled even for sync queue connection.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Security

If you discover any security issue, please email pro.ankurk1[at]gmail[dot]com instead of using the issue tracker.

License

This package is licensed under MIT License.