PHPackages                             ssigwart/aws-high-availability-sqs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. ssigwart/aws-high-availability-sqs

ActiveLibrary[Queues &amp; Workers](/categories/queues)

ssigwart/aws-high-availability-sqs
==================================

Library to make high availability SQS calls.

v1.0.3(2y ago)0311MITPHPPHP &gt;=8.0.0

Since Nov 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ssigwart/aws-high-availability-sqs)[ Packagist](https://packagist.org/packages/ssigwart/aws-high-availability-sqs)[ Docs](https://github.com/ssigwart/aws-high-availability-sqs)[ RSS](/packages/ssigwart-aws-high-availability-sqs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (1)

AWS High Availability SQS
=========================

[](#aws-high-availability-sqs)

This library makes it easy to write SQS messages with high availability. It includes the following features:

- Send any size message to SQS. If a message is too large, it will be stored in S3 and a reference to it will be stored in SQS.
- Send a message to one of multiple backup queues if the primary queue is unavailable.

Setup
-----

[](#setup)

You should set up at least 2 SQS queues and 2 S3 buckets in separate regions. The SQS queues are the messages you want to process. The S3 buckets will be used for oversized queue messages that are sent.

### S3 Lifecycle Rules

[](#s3-lifecycle-rules)

When deleting SQS messages that were backed by an S3 file, the code will attempt to delete the S3 file as well. However, in some cases, that S3 files may not be deleted. For example, it it advised to catch and ignore `AwsHighAvailabilitySqsDeleteS3FileDeletionFailureException` exceptions when calling `AwsHighAvailabilitySqsReceiver::deleteMessage`. Also, any messages that expire from the queue or end up going to the dead letter queue will note have the file deleted. Therefore, it is advised to set up lifecycle rules on the S3 bucket. You can find instructions on setting up object expiration at . 30 days is a safe bet.

Usage
-----

[](#usage)

The APIs require you to pass in an `\Aws\Sdk` object. In the examples below, `$awsSdk` is used for this object.

### Sending an SQS Message

[](#sending-an-sqs-message)

1. Create a list of available SQS queues to send to.
    - This is an `SqsAvailableQueues` object, which includes a primary queue and optional alternative queues.
2. Create a list of S3 buckets to back large messages.
    - This is and `S3AvailableUploadFileBucketAndKeyLocations` object.
    - You can add anything that implements `S3FileBucketAndKeyProviderInterface` to the list of locations.
    - The simplest option is to use `S3FileBucketAndKey`, which implements this interface.
3. Set up `SqsMessageSendingMetadata` with metadata for the message to be sent.
4. Create an `AwsHighAvailabilitySqsSender` object and call `sendMessageWithS3LargeMessageBacking`.
    - You can use the returned object to get the queue used and the message ID

```
// Set up SQS queues
$primaryQueue = new SqsAvailableQueue('us-east-1', 'https://sqs.us-east-1.amazonaws.com/123456789012/queue_in_us_east_1');
$backupQueue = new SqsAvailableQueue('us-east-2', 'https://sqs.us-east-2.amazonaws.com/123456789012/queue_in_us_east_2');
$availableQueues = new SqsAvailableQueues($primaryQueue);
$availableQueues->addAvailableQueue($backupQueue);

// Set up S3 locations
$primaryLocation = new S3FileBucketAndKey('us-east-1', 'phpunit-test-us-east-1', 'us-east-1/path/to/dir/');
$backupLocation = new S3FileBucketAndKey('us-east-2', 'phpunit-test-us-east-2', 'us-east-2/path/to/dir/');
$s3Locations = new S3AvailableUploadFileBucketAndKeyLocations($primaryLocation);
$s3Locations->addAlternativeLocation($backupLocation);

// Send messages
$sqsSender = new AwsHighAvailabilitySqsSender($awsSdk);
$result = $sqsSender->sendMessageWithS3LargeMessageBacking($availableQueues, $s3Locations, $queueMsgBody, null);
print 'Selected Queue: ' . $result->getSelectedQueue()->getQueueUrl() . PHP_EOL;
print 'Message ID: ' . $result->getSqsMessageId() . PHP_EOL;
```

### `SqsMessageSendingMetadata` Options

[](#sqsmessagesendingmetadata-options)

The `SqsMessageSendingMetadata` class allows you to customize the following when sending messages:

- SQS delivery delay.
- SQS message attributes.

### Receiving SQS Messages

[](#receiving-sqs-messages)

1. Create an `SqsAvailableQueue` object with the queue you want to receive from.
2. Set up `SqsMessageReceivingMetadata` with metadata for receiving messages.
3. Create an `AwsHighAvailabilitySqsReceiver` object and call `receivedMessagesWithS3LargeMessageBacking`.
    - The returned object includes the SQS messages, which you can get using `getSqsMessages`.

```
$primaryQueue = new SqsAvailableQueue('us-east-1', 'https://sqs.us-east-1.amazonaws.com/123456789012/queue_in_us_east_1');

// Set up metadata
$metadata = new SqsMessageReceivingMetadata();
$metadata->setMaxNumMessages(7);
$metadata->setVisibilityTimeout(300);
$metadata->setWaitTime(15);

$sqsReceiver = new AwsHighAvailabilitySqsReceiver($awsSdk);
$sqsMessagesResult = $sqsReceiver->receivedMessagesWithS3LargeMessageBacking($primaryQueue, $metadata);
print 'Number of Messages: ' . $sqsMessagesResult->getNumMessages() . PHP_EOL;
foreach ($sqsMessagesResult->getSqsMessages() as $sqsMessage)
{
	print 'Messages ID: ' . $sqsMessage->getMessageId() . PHP_EOL;
	print 'Receipt Handle: ' . $sqsMessage->getReceiptHandle() . PHP_EOL;
	print 'Message Body: ' . $sqsMessage->getMessage() . PHP_EOL;
}
```

### `SqsMessageReceivingMetadata` Options

[](#sqsmessagereceivingmetadata-options)

The `SqsMessageReceivingMetadata` class allows you to customize the following when receiving messages:

- Maximum number of messages to received (default: 10)
- SQS visibility timeout for messages received.
- SQS wait time when receiving messages.

### Deleting SQS Messages

[](#deleting-sqs-messages)

1. Create an `SqsAvailableQueue` object with the queue you want to delete from.
2. Create an `AwsHighAvailabilitySqsReceiver` object and call `deleteMessage`.
    - For any failures, a `AwsHighAvailabilitySqsDeleteException` will be thrown.
    - However, if a `AwsHighAvailabilitySqsDeleteS3FileDeletionFailureException` exception is thrown, the SQS message will have been successfully deleted, so it's advisable to ignore the exception besides possibly logging it.

```
$primaryQueue = new SqsAvailableQueue('us-east-1', 'https://sqs.us-east-1.amazonaws.com/123456789012/queue_in_us_east_1');
$sqsReceiver = new AwsHighAvailabilitySqsReceiver($awsSdk);
try {
	$sqsReceiver->deleteMessage($primaryQueue, $sqsMessage);
} catch (AwsHighAvailabilitySqsDeleteS3FileDeletionFailureException $e) {
	error_log($e->getMessage());
} catch (AwsHighAvailabilitySqsDeleteException $e) {
	// Handle error. Possibly try to delete it again or add application code to prevent the message from being processed again later.
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Total

4

Last Release

856d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1426848?v=4)[Stephen Sigwart](/maintainers/ssigwart)[@ssigwart](https://github.com/ssigwart)

---

Top Contributors

[![ssigwart](https://avatars.githubusercontent.com/u/1426848?v=4)](https://github.com/ssigwart "ssigwart (5 commits)")

---

Tags

awssqshigh availabilityHAmulti-region

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ssigwart-aws-high-availability-sqs/health.svg)

```
[![Health](https://phpackages.com/badges/ssigwart-aws-high-availability-sqs/health.svg)](https://phpackages.com/packages/ssigwart-aws-high-availability-sqs)
```

###  Alternatives

[dusterio/laravel-aws-worker

Run Laravel (or Lumen) tasks and queue listeners inside of AWS Elastic Beanstalk workers

3105.7M](/packages/dusterio-laravel-aws-worker)[shiftonelabs/laravel-sqs-fifo-queue

Adds a Laravel queue driver for Amazon SQS FIFO queues.

1556.0M3](/packages/shiftonelabs-laravel-sqs-fifo-queue)[dusterio/laravel-plain-sqs

Custom SQS connector for Laravel that supports custom format JSON

1352.7M1](/packages/dusterio-laravel-plain-sqs)[enqueue/sqs

Message Queue Amazon SQS Transport

376.3M14](/packages/enqueue-sqs)[joblocal/laravel-sqs-sns-subscription-queue

A simple Laravel service provider which adds a new queue connector to handle SNS subscription queues.

48416.3k](/packages/joblocal-laravel-sqs-sns-subscription-queue)[pod-point/laravel-aws-pubsub

A Laravel broadcasting driver and queue driver that broadcasts and listens to published events utilising AWS SNS, EventBridge and SQS.

1096.1k](/packages/pod-point-laravel-aws-pubsub)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
