PHP code example of piece601 / laravel-sqs-fifo-queue

1. Go to this page and download the library: Download piece601/laravel-sqs-fifo-queue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

piece601 / laravel-sqs-fifo-queue example snippets

 php
Piece601\LaravelSqsFifoQueue\LaravelSqsFifoQueueServiceProvider::class,
 php
'Piece601\LaravelSqsFifoQueue\LaravelSqsFifoQueueServiceProvider',
 php
$app->register(Piece601\LaravelSqsFifoQueue\LaravelSqsFifoQueueServiceProvider::class);
 php
dispatch(
    (new \App\Jobs\ProcessCoin())
        ->onMessageGroup('quarter')
        ->withDeduplicator('unique')
);
 php
$user->notify(
    (new InvoicePaid($invoice))->onMessageGroup($invoice->id)
);
 php
$this->app->bind('queue.sqs-fifo.deduplicator.random', function ($app) {
    return new \Piece601\LaravelSqsFifoQueue\Queue\Deduplicators\Callback(function ($payload, $queue) {
        // Return the deduplication id generated for messages. Randomly 0 or 1.
        return mt_rand(0,1);
    });
}
 php
namespace App\Deduplicators;

use Piece601\LaravelSqsFifoQueue\Contracts\Queue\Deduplicator;

class Random implements Deduplicator
{
    public function generate($payload, $queue)
    {
        // Return the deduplication id generated for messages. Randomly 0 or 1.
        return mt_rand(0,1);
    }
}
 php
$this->app->bind('queue.sqs-fifo.deduplicator.random', App\Deduplicators\Random::class);