PHP code example of marsberrys / laravel-sqs-plain-queue

1. Go to this page and download the library: Download marsberrys/laravel-sqs-plain-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/ */

    

marsberrys / laravel-sqs-plain-queue example snippets

 php
MarsBerrys\LaravelSqsPlainQueue\LaravelSqsPlainQueueServiceProvider::class,
 php
'MarsBerrys\LaravelSqsPlainQueue\LaravelSqsPlainQueueServiceProvider',
 php
$app->register(MarsBerrys\LaravelSqsPlainQueue\LaravelSqsPlainQueueServiceProvider::class);
 php
dispatch(
    (new \App\Jobs\ProcessCoin)
        ->onMessageGroup('quarter')
        ->withDeduplicator('unique')
);
 php
$this->app->bind('queue.sqs-plain.deduplicator.random', function ($app) {
    return new \MarsBerrys\LaravelSqsPlainQueue\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 MarsBerrys\LaravelSqsPlainQueue\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-plain.deduplicator.random', App\Deduplicators\Random::class);