-
Notifications
You must be signed in to change notification settings - Fork 0
queue:sqs
Joshua Estes edited this page Oct 4, 2017
·
4 revisions
The SqsQueue
allows you to use AWS SQS. It supports both Standard and FIFO queues.
You MUST install the AWS PHP SDK in order to use this queue.
composer require aws/aws-sdk-php
<?php
use Aws\Credentials\Credentials;
use Aws\Sqs\SqsClient;
use Dspacelabs\Component\Queue\SqsQueue;
$credentials = new Credentials($accessKey, $secretKey);
$client = new SqsClient([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => $credentials,
]);
/**
* $client = The SqsClient from the AWS SDK
* $queueUrl = The SQS Queue URL provided by AWS, just view the Queue details in AWS
* $name = The name you want to give your queue. This should be unique within your App
* and is not related to anything AWS
*/
$queue = new SqsQueue($client, $queueUrl, $name);
In order to use FIFO Queues you need to add some message attributes like this
$message->addAttribute('MessageGroupId', $messageGroupId);
$message->addAttribute('MessageDeduplicationId', $messageDepulicationId);
$queue->publish($message);