{"id":16023968,"url":"https://github.com/trandangtri/sqs-queue-bundle","last_synced_at":"2025-03-16T07:32:21.644Z","repository":{"id":56502119,"uuid":"95747104","full_name":"trandangtri/sqs-queue-bundle","owner":"trandangtri","description":"Simple SQS Queue Bundle for Symfony","archived":false,"fork":false,"pushed_at":"2022-10-10T08:35:00.000Z","size":115,"stargazers_count":27,"open_issues_count":8,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-27T05:50:57.135Z","etag":null,"topics":["amazon","aws-sqs","message-queue","php","queue-workers","sqs-queue","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trandangtri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-29T06:44:13.000Z","updated_at":"2022-10-10T14:40:06.000Z","dependencies_parsed_at":"2022-08-15T20:00:24.788Z","dependency_job_id":null,"html_url":"https://github.com/trandangtri/sqs-queue-bundle","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trandangtri%2Fsqs-queue-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trandangtri%2Fsqs-queue-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trandangtri%2Fsqs-queue-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trandangtri%2Fsqs-queue-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trandangtri","download_url":"https://codeload.github.com/trandangtri/sqs-queue-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806046,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","aws-sqs","message-queue","php","queue-workers","sqs-queue","symfony","symfony-bundle"],"created_at":"2024-10-08T19:04:55.081Z","updated_at":"2025-03-16T07:32:21.361Z","avatar_url":"https://github.com/trandangtri.png","language":"PHP","readme":"Simple AWS SQS Queue for Symfony\n================================\n\nThis bundle provides an easy way to work with AWS SQS\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/966e2515-0177-4b80-8ef0-cfc9bd800a81/mini.png)](https://insight.sensiolabs.com/projects/966e2515-0177-4b80-8ef0-cfc9bd800a81)\n[![Latest Stable Version](https://poser.pugx.org/tritran/sqs-queue-bundle/v/stable)](https://packagist.org/packages/tritran/sqs-queue-bundle)\n[![Latest Unstable Version](https://poser.pugx.org/tritran/sqs-queue-bundle/v/unstable)](https://packagist.org/packages/tritran/sqs-queue-bundle)\n[![Build Status](https://api.travis-ci.org/trandangtri/sqs-queue-bundle.svg?branch=master)](https://travis-ci.org/trandangtri/sqs-queue-bundle)\n[![codecov](https://codecov.io/gh/trandangtri/sqs-queue-bundle/branch/master/graph/badge.svg)](https://codecov.io/gh/trandangtri/sqs-queue-bundle)\n\nInstallation\n---\n\nFollow 5 quick steps to setup this bundle.\n\n### Step 1: Download the Bundle\n\nOpen a command console, enter your project directory and execute the following\ncommand to download the latest stable version of this bundle:\n\n```bash\n$ composer require tritran/sqs-queue-bundle\n```\n\n\u003e This command requires you to have Composer installed globally\n\n### Step 2: Enable the Bundle\n\nRegister bundles in `app/AppKernel.php`:\n\n```php\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        return [\n            // ...\n            new \\Aws\\Symfony\\AwsBundle(),\n            new \\TriTran\\SqsQueueBundle\\TriTranSqsQueueBundle(),\n        ];\n    }\n\n    // ...\n}\n```\n\n\u003e In a default Symfony application that uses [Symfony Flex](https://symfony.com/doc/current/setup/flex.html), bundles are enabled/disabled automatically for you when installing/removing them, so you could ignore this step.\n\n### Step 3: Update AWS SQS Credential\n\nThis bundle is using [AWS SDK for PHP](https://github.com/aws/aws-sdk-php-symfony). Full documentation of the configuration options available can be read in the [SDK Guide](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/configuration.html).\n\nBelow are sample configuration for AWS Credential in YAML format\n\n```yml\n# app/config/config.yml\n\naws:\n    version: latest\n    region: us-central-1\n    credentials:\n        key: not-a-real-key\n        secret: \"@not-a-real-secret\"\n```\n\n### Step 4: Configure the Queues\n\nBelow are sample configuration for some queues in YAML format\n\n```yml\n# app/config/config.yml\n\ntritran_sqs_queue:\n    sqs_queue:\n        queues:\n            emailpool:\n                queue_url: 'https://sqs.eu-central-1.amazonaws.com/49504XX59872/emailpool'\n                worker: \"@acl.service.emailpool\"\n                attributes:\n                    receive_message_wait_time_seconds: 20\n                    visibility_timeout: 30\n            reminder:\n                queue_url: 'https://sqs.eu-central-1.amazonaws.com/49504XX59872/reminder'\n                worker: 'AclBundle\\Service\\Worker\\ReminderWorker'\n```\n\nFull documentation of the queue options available can be read in the [Queue Attributes](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html).\n\n\u003e Now, you could access to queue `emailpool` or `reminder` service via `tritran.sqs_queue.emailpool` or `tritran.sqs_queue.reminder`, it's an interface of [BaseQueue](https://github.com/trandangtri/sqs-queue-bundle/blob/master/Service/BaseQueue.php)\n\nBelow are a sample implementation of sending a message to a specified queue\n\n```php\nnamespace AclBundle\\Controller;\n\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller;\nuse TriTran\\SqsQueueBundle\\Service\\Message;\n\n/**\n * Class DefaultController\n *\n * @package AclBundle\\Controller\n */\nclass DefaultController extends Controller\n{\n    public function indexAction()\n    {\n        // ...\n        \n        $data = [\n            'from' =\u003e 'sender@domain.com',\n            'to' =\u003e 'receiver@domain.com',\n            'subject' =\u003e 'Greeting Message',\n            'body' =\u003e 'Congratulation! You have just received a message which was sent from AWS SQS Queue'\n        ];\n        $this-\u003eget('tritran.sqs_queue.emailpool')\n            -\u003esendMessage((new Message())-\u003esetBody(serialize($data)));\n\n        // ...\n    }\n}\n```\n\n\u003e For a FIFO queue, you must associate a non-empty `MessageGroupId` with a message. Otherwise, the action fails.\u003cbr/\u003e\n\u003e You may provide a `MessageDeduplicationId` explicitly. If you aren't able to provide a `MessageDeduplicationId` and you enable `ContentBasedDeduplication` for your queue, Amazon SQS uses a SHA-256 hash to generate the `MessageDeduplicationId` using the body of the message (but not the attributes of the message).\u003cbr /\u003e\n\u003e For more information about FIFO queue, please take a look at [Amazon SQS FIFO (First-In-First-Out) Queues](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html)\n\n#### Queue Behaviours\n\n|Behaviour|Arguments|Description|\n|---|---|---|\n|sendMessage|`Message` $message\u003cbr /\u003e`int` $delay = 0|Delivers a message to the specified queue.|\n|receiveMessage|`int` $limit = 1|Retrieves one or more messages (up to 10), from the specified queue. Using the WaitTimeSeconds parameter enables long-poll support. For more information, see [Amazon SQS Long Polling](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html) in the Amazon SQS Developer Guide.|\n|deleteMessage|`string` $receiptHandle|Deletes the specified message from the specified queue. You specify the message by using the *message's receipt handle* and not the *MessageId* you receive when you send the message. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue. If you leave a message in the queue for longer than the queue's configured retention period, Amazon SQS automatically deletes the message.|\n|purge|    |Deletes the messages in a queue specified by the QueueURL parameter. **Note**: you can't retrieve a message deleted from a queue.|\n\n#### Queue Manager Behaviours\n\n\u003e You could access [QueueManager](https://github.com/trandangtri/sqs-queue-bundle/blob/master/Service/QueueManager.php) via service `tritran.sqs_queue.queue_manager`\n\n|Behaviour|Arguments|Description|\n|---|---|---|\n|listQueue|`string` $prefix = ''|Returns a list of your queues. The maximum number of queues that can be returned is 1,000. If you specify a value for the optional *prefix* parameter, only queues with a name that begins with the specified value are returned.|\n|createQueue|`string` $queueName\u003cbr /\u003e`array` $queueAttribute|Creates a new standard or FIFO queue. You can pass one or more attributes in the request.|\n|deleteQueue|`string` $queueUrl|Deletes the queue specified by the **QueueUrl**, regardless of the queue's contents. If the specified queue doesn't exist, Amazon SQS returns a successful response.|\n|setQueueAttributes|`string` $queueUrl\u003cbr /\u003e`array` $queueAttribute|Sets the value of one or more queue attributes. When you change a queue's attributes, the change can take up to 60 seconds for most of the attributes to propagate throughout the Amazon SQS system|\n|getQueueAttributes|`string` $queueUrl|Gets attributes for the specified queue.|\n\n### Step 5: Setup a worker\n\nBelow are a sample implementation of a worker, which will listen to a queue to handle the messages inside.\n\n```php\nnamespace AclBundle\\Service\\Worker;\n\nuse TriTran\\SqsQueueBundle\\Service\\Message;\nuse TriTran\\SqsQueueBundle\\Service\\Worker\\AbstractWorker;\n\nclass ReminderWorker extends AbstractWorker\n{\n    /**\n     * @param Message $message\n     *\n     * @return boolean\n     */\n    protected function execute(Message $message)\n    {\n        echo 'The message is: ' . $message-\u003egetBody();\n\n        return true;\n    }\n}\n```\n\nAnd then you could make it executed as daemon in console via:\n\n```bash\nbin/console tritran:sqs_queue:worker reminder\n```\n\n\u003e Note: **reminder** is the name of queue which you configured in the config.yml in step 4.\n\n### Appendix: Useful Console Commands\n\n|Behaviour|Description|\n|---|---|\n|tritran:sqs_queue:create|Creates a new standard or FIFO queue. You can pass one or more attributes in the request.|\n|tritran:sqs_queue:update|Update queue attribute based on its configuration which shown in config.yml|\n|tritran:sqs_queue:delete|Delete a queue by url and all its messages||\n|tritran:sqs_queue:attr|Retrieve the attribute of a specified queue|\n|tritran:sqs_queue:purge|Deletes the messages in a queue specified by the QueueURL parameter.|\n|tritran:sqs_queue:worker|Start a worker that will listen to a specified SQS queue|\n|tritran:sqs_queue:ping|Send a simply message to a queue, for DEBUG only|\n\n\u003e Note: Please using `-h` for more information for each command.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrandangtri%2Fsqs-queue-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrandangtri%2Fsqs-queue-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrandangtri%2Fsqs-queue-bundle/lists"}