Skip to content

Commit 028469a

Browse files
committed
allow clearing sqs queues
1 parent 1c57ab5 commit 028469a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Illuminate/Queue/SqsQueue.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
namespace Illuminate\Queue;
44

55
use Aws\Sqs\SqsClient;
6+
use Illuminate\Contracts\Queue\ClearableQueue;
67
use Illuminate\Contracts\Queue\Queue as QueueContract;
78
use Illuminate\Queue\Jobs\SqsJob;
89
use Illuminate\Support\Str;
910

10-
class SqsQueue extends Queue implements QueueContract
11+
class SqsQueue extends Queue implements QueueContract, ClearableQueue
1112
{
1213
/**
1314
* The Amazon SQS instance.
@@ -139,6 +140,23 @@ public function pop($queue = null)
139140
}
140141
}
141142

143+
/**
144+
* Delete all of the jobs from the queue.
145+
*
146+
* @param string $queue
147+
* @return int
148+
*/
149+
public function clear($queue)
150+
{
151+
$size = $this->size($queue);
152+
153+
$this->sqs->purgeQueue([
154+
'QueueUrl' => $this->getQueue($queue),
155+
]);
156+
157+
return $size;
158+
}
159+
142160
/**
143161
* Get the queue or return the default.
144162
*

0 commit comments

Comments
 (0)