PHP code example of shiftonelabs / laravel-sqs-fifo-queue
1. Go to this page and download the library: Download shiftonelabs/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/ */
shiftonelabs / laravel-sqs-fifo-queue example snippets
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 \ShiftOneLabs\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 ShiftOneLabs\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);
}
}