This is a Amazon SQS POC using Laravel 5.6
The instructions below shows the steps to run this POC:
- Clone this repository
- Use
docker-compose up -d
to start the PHP container - Copy .env.example to .env
- Change permissions for
storage
andbootstrap/cache
folders usingsudo chown -R http:http <folder_name>
- Enter on PHP docker container bash using
docker-compose exec php bash
and navigate to/var/www
- Run
composer install
to install all dependencies - Run
php artisan key:generate
to generate .env APP_KEY - exit PHP docker container bash using
exit
- Using your web browser, go to http://localhost and you will see your welcome page
- Create an IAM user on AWS Panel with
AmazonSQSFullAccess
policy - Replace the QUEUE_DRIVER on .env to
sqs
- Use the IAM Key and Secret and replace the SQS_KEY and SQS_SECRET on .env, respectively
- Create a SQS queue on AWS Panel
- Replace SQS_QUEUE config on .env with the queue name
- Replace SQS_REGION config on .env with the region where the quere is
- Replace SQS_PREFIX config on .env with the queue URL (without the queue name at the end)
- From the welcome page, click on
TEST A SINGLE QUEUE
orTEST A CHAINED QUEUE
and you should see that the message was sent to SQS! (I hope! :D) - Verify SQS Panel on AWS and see that your queue has a new message (only if you disable supervisor on docker container, otherwise it will be hard to see the messages on Amazon SQS Panel)
Usedocker-compose exec php bash
, navigate to/var/www
and runphp artisan queue:work
. You should see that ProcessStandard Job was executed. (Usectrl + C
to stop)Go to/var/www/storage/logs/laravel.log
and you should see some Jobs strings (I hope again! :D)- The
supervisor
will be running 2 worker to process your queue. So you don't need to be worry about that, just openstorage/logs/amazon-sqs-worker.log
to see which Job was processed or go tostorage/logs/laravel.log
to see some Jobs strings (to simulate the work that should be done).