Download the PHP package dirk39/sqs-manager without Composer
On this page you can find all versions of the php package dirk39/sqs-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dirk39/sqs-manager
More information about dirk39/sqs-manager
Files in dirk39/sqs-manager
Package sqs-manager
Short Description Simple library that fetch and manage messages from SQS Queue
License mit
Informations about the package sqs-manager
SQS Manager
SQS Manager is a library that simplifies fetching of messages from a SQS Queue. SQS Manager reads messages from the queue you want, prepares a SQSManager\Message object and pass it to function or method you define. The main advantages of this libray are:
- After the message has been depleted will be deleted from the queue by the Manager.
- If an exception is caught by the Manager, remaining messages will be released and the caught exception will be thrown.
- If the Manager retrieves several messages, it will pass them one by one to designed method/function. Afterwards the Manager will check
VisibilityTimeoutof remaining messages and in case of short expiry date, it will extend the expiration according to theVisibilityTimeoutvalue. According to the AWS SQS documetation, the maximum timeout is 12 hours.
Installation
SQSManager can be installed by composer
Documentation
Usage of SQS Manager is very straightforward.
Construct
In $additional_conf array you can add custom configuration for the Aws\Sqs\SqsClient. You can find more information about additional conf here.
Fetch messages
$queueName: the name of the queue you need to fetch.$queuecould be the name of the queue or its url.$callback: $callback value will be passed to acall_user_func. Read the docs about acceptable $callback values. The Manager will pass aSQSManager\Messageobject to your callback function/method.$listenerConfigs: additional configs pass toAws\Sqs\SqsClient::receiveMessagemethod. For further information about allowed configs read here
Manager configurators
changeVisibilityTimeout: change defaultVisibilityTimeoutvalue. It must be an integer between and 0 and 43200 seconds (i.e. 12 hours)setWaitTimeSeconds: change defaultWaitTimeSecondsvalue. It must be an integer between and 1 and 20 seconds.-
setMaxNumberOfMessages: change defaultMaxNumberOfMessagesvalue. It must be an integer between and 1 and 10.Testing
To replicate integration tests you have to copy
tests/config.example.phpintotests/configs.phpand replace default values forAWS_KEY,AWS_SECRET,AWS_REGION,AWS_QUEUE_NAMEwith your values. Important: AWS credentials must be of a user with read/write permission for Amazon SQS. At the end of the tests, designed queue will be purged of all messages so don't use production SQS queue!