- This package is for doing jobs with high reliability
run composer require daalvand/retry-policy
php artisan vendor:publish --provider="Daalvand\RetryPolicy\RetryPolicyServiceProvider"
- Add the service provider to
bootstrap/app.php
file:
<?php
//...
/** @var App $app */
$app->register(Daalvand\RetryPolicy\RetryPolicyServiceProvider::class);
Copy the config files from /vendor/daalvand/retry-policy/src/config
to config
directory. Then configure it in /bootstrap/app.php
file:
<?php
/** @var App $app */
$app->configure("retry-policy");
- extends your retryable from
Retryable abstract
:
<?php
use \Daalvand\RetryPolicy\Contracts\Retryable;
//Custom Class
class CustomRetryable extends Retryable
{
public function execute() : bool
{
// TODO: Implement execute() method.
}
}
#### Create an object from custom retryable
use Daalvand\RetryPolicy\Facades\RetryContext;
$retryable = new CustomRetryable();
$retryable
->setMaxRequeue(20)
->setMaxRetry(2)
->setRetryDelay(10)
->setRqueueDelay(3600);
//retry retryables
RetryContext::perform([$retryable]);
retry_policy:consumer
retry_policy:requeue
`