本文整理汇总了PHP中Aws\Sqs\SqsClient::deleteMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP SqsClient::deleteMessage方法的具体用法?PHP SqsClient::deleteMessage怎么用?PHP SqsClient::deleteMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\Sqs\SqsClient
的用法示例。
在下文中一共展示了SqsClient::deleteMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processMessage
/**
* Process a single message and push it to the server URL
*
* @link http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html
* @param array $message
* @param string $uri
* @param string $queueName
* @param string $queueUrl
* @param OutputInterface $output
* @return void
*/
private function processMessage(array $message, string $uri, string $queueName, string $queueUrl, OutputInterface $output)
{
$response = $this->httpClient->post($uri, ['headers' => ['User-Agent' => 'aws-sqsd/2.0', 'Content-Type' => 'application/json', 'X-Aws-Sqsd-Msgid' => $message['MessageId'], 'X-Aws-Sqsd-Queue' => $queueName, 'X-Aws-Sqsd-First-Received-At' => $message['Attributes']['ApproximateFirstReceiveTimestamp'], 'X-Aws-Sqsd-Receive-Count' => $message['Attributes']['ApproximateReceiveCount'], 'X-Aws-Sqsd-Sender-Id' => $message['Attributes']['SenderId']], 'json' => json_decode($message['Body'], true)]);
if ($response->getStatusCode() === 200) {
$this->sqsClient->deleteMessage(['QueueUrl' => $queueUrl, 'ReceiptHandle' => $message['ReceiptHandle']]);
$output->writeln(sprintf('<info>Message "%s" has been processed and deleted from the queue "%s".</info>', $message['MessageId'], $queueName));
} else {
$output->writeln(sprintf('<error>Message "%s" could not be processed and back-end returned error %s. Reason: %s</error>', $message['MessageId'], $response->getStatusCode(), $response->getBody()));
}
}
示例2: delete
/**
* {@inheritDoc}
*/
public function delete(MessageInterface $message)
{
if (null === $message->getAttribute('ReceiptHandle')) {
throw new QueueException('Message does not contain ReceiptHandle');
}
$result = $this->client->deleteMessage(array('ReceiptHandle' => $message->getAttribute('ReceiptHandle'), 'QueueUrl' => $this->queueUrl));
}
示例3: ack
/**
* @inheritDoc
*/
public function ack($queueName, Envelope $envelope)
{
if (!$envelope instanceof SqsEnvelope) {
throw new InvalidEnvelope(sprintf('%s requires that envelopes be instances of "%s", got "%s"', __CLASS__, SqsEnvelope::class, get_class($envelope)));
}
$queueUrl = $this->getQueueUrl($queueName);
$this->client->deleteMessage(['QueueUrl' => $queueUrl, 'ReceiptHandle' => $envelope->getReceiptHandle()]);
}
示例4: deleteMessage
/**
* @inheritdoc
*
* @throws \InvalidArgumentException
* @throws InvalidMessageException
* @throws QueueAccessException
*/
public function deleteMessage($queueName, $message)
{
if (empty($queueName)) {
throw new \InvalidArgumentException('Queue name empty or not defined.');
}
if (empty($message)) {
throw new InvalidMessageException($message, 'Message empty or not defined.');
}
if (!is_array($message)) {
throw new InvalidMessageException($message, 'Message must be an array.');
}
if (!isset($message['ReceiptHandle'])) {
throw new InvalidMessageException($message, 'ReceiptHandle not found in message.');
}
if (!isset($message['priority'])) {
throw new InvalidMessageException($message, 'Priority not found in message.');
}
$priority = $this->priorityHandler->getPriorityByLevel($message['priority']);
try {
$queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
$this->sqsClient->deleteMessage(['QueueUrl' => $queueUrl, 'ReceiptHandle' => $message['ReceiptHandle']]);
} catch (SqsException $e) {
throw new QueueAccessException('Cannot delete message from queue.', 0, $e);
}
return $this;
}
示例5: remove
/**
* Remove permanently a particular message from the queue
*
* @param MessageInterface $message
* @throws \Qu\Exception\OperationException
* @return void
*/
public function remove(MessageInterface $message)
{
try {
$this->client->deleteMessage(['QueueUrl' => $this->getUrl(), 'ReceiptHandle' => $message->getMetadata(static::RECEIPT_HANDLE_KEY)]);
} catch (\Exception $e) {
throw new OperationException($e->getMessage(), 0, $e);
}
$message->setMetadata(static::RECEIPT_HANDLE_KEY, null);
}
示例6: deleteJob
/**
* Delete the job from the queue.
*
* @param Job $job The job to be deleted.
*
* @return boolean whether the operation succeed.
*/
public function deleteJob(Job $job)
{
if (!empty($job->header['ReceiptHandle'])) {
$receiptHandle = $job->header['ReceiptHandle'];
$response = $this->_client->deleteMessage(['QueueUrl' => $this->url, 'ReceiptHandle' => $receiptHandle]);
return $response !== null;
} else {
return false;
}
}
示例7: delete
/**
* {@inheritDoc}
*
* @return bool
*/
public function delete($id)
{
if (!$this->queueExists()) {
return false;
}
$this->sqs->deleteMessage(['QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $id]);
$context = ['QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $id];
$this->log(200, "Message deleted from SQS Queue", $context);
return true;
}
示例8: delete
/**
* Deletes a message from the queue
*
* @param Message $message
* @return bool returns true if successful, false otherwise
*/
public function delete(Message $message)
{
try {
// Delete the message
$this->sqs_client->deleteMessage(array('QueueUrl' => $this->url, 'ReceiptHandle' => $message->receipt_handle));
return true;
} catch (Exception $e) {
echo 'Error deleting message from queue ' . $e->getMessage();
return false;
}
}
示例9: deleteSqsMessage
/**
* @param mixed[] $args
* @return Result
* @throws ExceptionInterface
*/
private function deleteSqsMessage(array $args = [])
{
if (array_key_exists('ReceiptHandle', $args) && $this->configuration->getDeleteFromS3()) {
// Split receipt handle into S3 and SQS information.
$decodedReceiptHandle = json_decode($args['ReceiptHandle'], true);
if (json_last_error() === JSON_ERROR_NONE) {
$s3Client = $this->configuration->getS3Client();
// Delete from S3.
$s3Client->deleteObject(array('Bucket' => $decodedReceiptHandle['s3_bucket_name'], 'Key' => $decodedReceiptHandle['s3_key']));
// Adjust SQS args.
$args['ReceiptHandle'] = $decodedReceiptHandle['original_receipt_handle'];
}
}
return $this->sqsClient->deleteMessage($args);
}
示例10: wait
/**
* {@inheritdoc}
*/
public function wait(Closure $callback)
{
while (true) {
$result = $this->client->receiveMessage(array('QueueUrl' => $this->queueUrl, 'WaitTimeSeconds' => 20));
$messages = $result['Messages'];
if ($messages) {
foreach ($messages as $message) {
$hermesMessage = $this->serializer->unserialize($message['Body']);
$callback($hermesMessage);
$this->client->deleteMessage(array('QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $message['ReceiptHandle']));
}
}
if ($this->sleepInterval) {
sleep($this->sleepInterval);
}
}
}
示例11: deleteMessage
/**
* @inheritdoc
*
* @throws SqsException
*/
public function deleteMessage($queueName, $message)
{
if (empty($queueName)) {
throw new InvalidArgumentException('Parameter queueName empty or not defined.');
}
if (empty($message)) {
throw new InvalidArgumentException('Parameter message empty or not defined.');
}
if (!is_array($message)) {
throw new InvalidArgumentException('message must be an array.');
}
if (!isset($message['ReceiptHandle'])) {
throw new InvalidArgumentException('ReceiptHandle not found in message.');
}
if (!isset($message['priority'])) {
throw new InvalidArgumentException('Priority not found in message.');
}
$queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $message['priority'])])->get('QueueUrl');
$this->sqsClient->deleteMessage(['QueueUrl' => $queueUrl, 'ReceiptHandle' => $message['ReceiptHandle']]);
return $this;
}
示例12: delete
/**
* {@inheritDoc}
*/
public function delete(JobInterface $job)
{
$parameters = array('QueueUrl' => $this->queueOptions->getQueueUrl(), 'ReceiptHandle' => $job->getMetadata('receiptHandle'));
$this->sqsClient->deleteMessage($parameters);
}
示例13: completeMessage
/**
* {@inheritDoc}
*/
public function completeMessage(QueueMessage $message)
{
$queueUrl = $this->getQueueUrl($message->getQueueId());
$this->queueClient->deleteMessage(["QueueUrl" => $queueUrl, "ReceiptHandle" => $message->getReceiptId()]);
}
示例14: SqsClient
require '../vendor/autoload.php';
use Aws\Sqs\SqsClient;
use Aws\S3\S3Client;
$s3 = new S3Client(['version' => S3_VERSION, 'region' => S3_REGION]);
$sqs = new SqsClient(['version' => SQS_VERSION, 'region' => SQS_REGION]);
$messageResult = $sqs->receiveMessage(array('QueueUrl' => SQS_OUTBOX, 'MaxNumberOfMessages' => 10, 'MessageAttributeNames' => array('s3path', 's3bucket', 'filename', 'smallfilename')));
$message = "";
if ($messageResult->getPath('Messages') != '') {
foreach ($messageResult->getPath('Messages') as $messages) {
$attr = array();
$receiptHandle = $messages['ReceiptHandle'];
foreach ($messages['MessageAttributes'] as $key => $value) {
$attr[$key] = $value['StringValue'];
$message = $attr['filename'] . " Resize Done.<br/>";
}
$sqs->deleteMessage(array('QueueUrl' => SQS_OUTBOX, 'ReceiptHandle' => $receiptHandle));
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AWS EC2 S3 SQS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet"
示例15: deleteMessage
public function deleteMessage(SqsReceivedMessage $msg)
{
$this->client->deleteMessage(["QueueUrl" => $this->getQueueUrl(), "ReceiptHandle" => $msg->getReceiptHandle()]);
}