diff --git a/src/Illuminate/Queue/SqsQueue.php b/src/Illuminate/Queue/SqsQueue.php index 80a08decbe5d..b54d731240fe 100755 --- a/src/Illuminate/Queue/SqsQueue.php +++ b/src/Illuminate/Queue/SqsQueue.php @@ -3,11 +3,12 @@ namespace Illuminate\Queue; use Aws\Sqs\SqsClient; +use Illuminate\Contracts\Queue\ClearableQueue; use Illuminate\Contracts\Queue\Queue as QueueContract; use Illuminate\Queue\Jobs\SqsJob; use Illuminate\Support\Str; -class SqsQueue extends Queue implements QueueContract +class SqsQueue extends Queue implements QueueContract, ClearableQueue { /** * The Amazon SQS instance. @@ -139,6 +140,23 @@ public function pop($queue = null) } } + /** + * Delete all of the jobs from the queue. + * + * @param string $queue + * @return int + */ + public function clear($queue) + { + $size = $this->size($queue); + + $this->sqs->purgeQueue([ + 'QueueUrl' => $this->getQueue($queue), + ]); + + return $size; + } + /** * Get the queue or return the default. *