Steps to reproduce:
-
composer install
-
cp .env.example .env
-
Create sqlite database
touch database/db.sqlite php artisan migrate
-
Start local dynamodb
docker run --rm -p 8000:8000 amazon/dynamodb-local:latest -jar DynamoDBLocal.jar -inMemory -sharedDb
-
Create
cache
table in dynamodbAWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_REGION=test aws dynamodb --endpoint=http://localhost:8000/ create-table --table-name cache --attribute-definitions AttributeName=key,AttributeType=S --key-schema AttributeName=key,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
-
Start at least two worker processes
php artisan queue:work & php artisan queue:work
-
dispatch sample job two times
php artisan tinker --execute="\App\Jobs\SlowJob::dispatch();" && sleep 2 && php artisan tinker --execute="\App\Jobs\SlowJob::dispatch();"
-
check logs
tail storage/logs/laravel.log #=> [2022-07-19 12:50:18] local.INFO: Start: 2022-07-19 12:50:18 [2022-07-19 12:50:22] local.INFO: Start: 2022-07-19 12:50:22 [2022-07-19 12:50:23] local.INFO: End: 2022-07-19 12:50:23 [2022-07-19 12:50:27] local.INFO: End: 2022-07-19 12:50:27
Two jobs are executed in parallel.