Skip to content

Commit

Permalink
Merge pull request #7 from kfzteile24/DEV-39444_Add_DeleteMessage_Pur…
Browse files Browse the repository at this point in the history
…geQueue_Methods

[DEV-39444]Add purgeQueue and deleteMessageBatch methods
  • Loading branch information
Alymosul authored Mar 6, 2023
2 parents 7841478 + 2c5d46d commit abf9f0c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Client/Aws/SqsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,53 @@ public function deleteMessageBatchAsync(array $args = []): Promise
return parent::deleteMessageBatchAsync($args);
}

/**
* @param array $args
*
* @return Result
*/
public function deleteMessageBatch(array $args = []): Result
{
if ($this->largePayloadMessageExtension === null) {
/** @noinspection PhpUndefinedMethodInspection */
return parent::deleteMessageBatch($args);
}

$originalReceipts = [];

foreach ($args[self::ENTRIES] as $receipt) {
if (!$this->largePayloadMessageExtension->isS3ReceiptHandle($receipt[self::RECEIPT_HANDLE])) {
$originalReceipts[] = $receipt;
continue;
}

$this->largePayloadMessageExtension->deleteMessageFromS3($receipt[self::RECEIPT_HANDLE]);

$originalReceiptHandle = $this->largePayloadMessageExtension->getOriginalReceiptHandle(
$receipt[self::RECEIPT_HANDLE]
);

$originalReceipt = $receipt;
$originalReceipt[self::RECEIPT_HANDLE] = $originalReceiptHandle;
$originalReceipts[] = $originalReceipt;
}

$args[self::ENTRIES] = $originalReceipts;

/** @noinspection PhpUndefinedMethodInspection */
return parent::deleteMessageBatch($args);
}

/**
* @param array $args
*
* @return Result
*/
public function purgeQueue(array $args = []): Result
{
return parent::purgeQueue($args);
}

/**
* @param array $body
*
Expand Down

0 comments on commit abf9f0c

Please sign in to comment.