added retries back to mail functionality
This commit is contained in:
@@ -37,10 +37,10 @@ class ProcessSendEveMailJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retries
|
* Retries
|
||||||
* With new rate limiting, we shouldn't use this timeout
|
* With new rate limiting, we need a retry basis versus timeout basis
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
//public $retries = 3;
|
public $retries = 5;
|
||||||
|
|
||||||
private $sender;
|
private $sender;
|
||||||
private $body;
|
private $body;
|
||||||
@@ -166,6 +166,9 @@ class ProcessSendEveMailJob implements ShouldQueue
|
|||||||
|
|
||||||
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
|
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
|
||||||
$rateLimitedMiddleware = (new RateLimited())
|
$rateLimitedMiddleware = (new RateLimited())
|
||||||
|
->enabled()
|
||||||
|
->key('psemj')
|
||||||
|
->connectionName('redis')
|
||||||
->allow(4)
|
->allow(4)
|
||||||
->everySeconds(60)
|
->everySeconds(60)
|
||||||
->releaseAfterOneMinute()
|
->releaseAfterOneMinute()
|
||||||
|
|||||||
@@ -42,13 +42,6 @@ class ProcessSendEveMailJobRL implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
//public $retries = 3;
|
//public $retries = 3;
|
||||||
|
|
||||||
/**
|
|
||||||
* Middleware for the job
|
|
||||||
*
|
|
||||||
* @var \Spatie\RateLimitedMiddleware\RateLimited
|
|
||||||
*/
|
|
||||||
private $middleware;
|
|
||||||
|
|
||||||
private $sender;
|
private $sender;
|
||||||
private $body;
|
private $body;
|
||||||
private $recipient;
|
private $recipient;
|
||||||
@@ -126,9 +119,11 @@ class ProcessSendEveMailJobRL implements ShouldQueue
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function middleware() {
|
public function middleware() {
|
||||||
|
|
||||||
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
|
|
||||||
$rateLimitedMiddleware = (new RateLimited())
|
$rateLimitedMiddleware = (new RateLimited())
|
||||||
|
->enabled()
|
||||||
|
->key('PSEMJ')
|
||||||
|
->connectionName('redis')
|
||||||
->allow(4)
|
->allow(4)
|
||||||
->everySeconds(60)
|
->everySeconds(60)
|
||||||
->releaseAfterOneMinute()
|
->releaseAfterOneMinute()
|
||||||
@@ -137,6 +132,27 @@ class ProcessSendEveMailJobRL implements ShouldQueue
|
|||||||
return [$rateLimitedMiddleware];
|
return [$rateLimitedMiddleware];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function OtherCode() {
|
||||||
|
//Can also specify middleware when dispatch a job.
|
||||||
|
//SomeJob::dispatch()->through([new SomeMiddleware]);
|
||||||
|
|
||||||
|
//Current method of creating job handle with redis throttle
|
||||||
|
/**
|
||||||
|
* public function handle()
|
||||||
|
* {
|
||||||
|
* Redis::throttle('key')->allow(10)->every(60)->then(function () {
|
||||||
|
* // Job logic...
|
||||||
|
* }, function () {
|
||||||
|
* // Could not obtain lock...
|
||||||
|
* return $this->release(10);
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the time at which the job should timeout.
|
* Determine the time at which the job should timeout.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user