Download the PHP package beyerz/aws-queue-bundle without Composer
On this page you can find all versions of the php package beyerz/aws-queue-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beyerz/aws-queue-bundle
More information about beyerz/aws-queue-bundle
Files in beyerz/aws-queue-bundle
Package aws-queue-bundle
Short Description Symfony bundle to connect AWS sns and sqs to create offline queue processing
License
Informations about the package aws-queue-bundle
AWS Queue Bundle
About
AWS Queue Bundle for Symfony2
The purpose of this bundle is to provide an easy integration between symfony services and AWS services. Queues are defined by Producers and Consumers
By using this bundle, together with aws bundle, the Consumer and Producer services that you define will automatically setup the AWS services on demand. This eases the requirement of setting up your queue and notification services through the AWS platform.
Installation
Composer (Recommended)
Application Kernel
Add BeyerzAWSQueueBundle to the registerBundles()
method of your application kernel:
Usage
Config
config.yml
Important config note:
Due to the way that Aws has defined the working tree, the aws-queue-bundle cannot automatically append your configs.
The result of this is that you will need to define the aws configuration yourself.
Documentation
Creating a Producer
Creating a producer that can be used in your system is really simple, here is some sample code to get you started You can also look at the demo folder in this bundle AcmeBundle/Producers/MyAwesomeProducer.php
Producers require some setup which is handled by this bundle and you dont really have to worry too much about it. We have provided both and interface and trait for producers and as long you have included them, the setup should go smoothly.
Next, we need to define the producer as a service so that we can tag it and make the AwsQueueBundle aware that it exists :)
AcmeBundle/Resources/config/services.yml
You can now access your producer as you normally would through symfony container
After running this producer, you can go to SNS service in your amazon account and see a new topic has been created for you. You will not yet have queues in your SQS as we have not yet created any consumers
Creating a Consumer
Consumer are a little more complex than producers, but the basic concept to understand is that your consumer class receives the message from the queue for you to process.
AcmeBundle/Consumers/MyAwesomeConsumer.php
Consumers require some setup which is handled by this bundle and you dont really have to worry too much about it. We have provided both an interface and as long you have implemented it, the setup should go smoothly. Your consumer class gets "wrapped" in a special consumer service. This wrapper connects to the queue and passes the message to your consume function. This wrapper loads your consumer using service container, this means that you can create your service as you normally would, so you can even add dependecies to a constructor!
Next, we need to define the consumer as a service so that we can tag it and make the AwsQueueBundle aware that it exists :) There are two tags that we are going to use. The first tag tells the bundle that this is a consumer and the defines the name of the SQS queue using the channel key The second tag tells the bundle which producer this consumer wants to subscribe to. If you want to subscribe this queue to more than one producer, just duplicate the tag and define the producer name accordingly
AcmeBundle/Resources/config/services.yml
Now you can run your producer using cli
Your consumer will keep running unless you specify a max message limit or something crashes. Its probably best to start your consumers using a task management system such as supervisor or even jenkins. If you have processes that you prefer to run at specific times and not continuosly you can also use crontab
All versions of aws-queue-bundle with dependencies
aws/aws-sdk-php-symfony Version ^2.0.0
symfony/symfony Version ^2.8|^3.0|^3.1|^3.2|^3.3