-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to Laravels own queue worker #13
Switch to Laravels own queue worker #13
Conversation
use Illuminate\Queue\Events\JobProcessed; | ||
use Illuminate\Queue\Events\JobProcessing; | ||
use Illuminate\Queue\Events\JobExceptionOccurred; | ||
use CacheWerk\BrefLaravelBridge\MaintenanceMode; | ||
|
||
class QueueHandler extends SqsHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vapor uses the VAPOR_QUEUE_DATABASE_SESSION_PERSIST
option to keep database connections open between SQS events, should we add this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tillkruss Without a doubt!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JackEllis This looks good to me now. Any feedback?
@georgeboot pointed out in Slack:
Currently there are no database disconnects, which means connections always stay open between invocations. AFAICT this is the case for web, artisan and queue. Only the octane client optionally disconnects.
How is this not the framework default?! 🤷♂️ |
Jup, good question. We could reverse the behaviour and enable it by default? Would be a better 'out of the box' experience. |
Yes please. |
done |
This PR adds a more native queue handler. It tries to utilise as many internal Laravel components as possible, to stay as close to the other queue implementations as possible.
It's worth noticing that due to the way Lambda timeouts and SQS's integration with Lambda works, it's probably best to run with a
batchSize
of 1. If you want a larger batch size, make sure your jobs are designed in such a way that it won't break things if they are run more than once.This package will add a timeout value (calculated for each job by subtracting a safety margin from the remaining invocation time) that will trigger a job timeout exception if the job is configured to do so.
Configuring a job to raise a failed exception on timeout can be done by adding the following to the job class:
When is this is set, the handler will catch the timeout, flag the job as failed and push it back onto the queue with it's attempts incremented with 1.
If the above is not set, the worker will not catch the timeout, and after SQS's visibility timeout expires, the job will be retried with the attempts NOT incremented.
Closes #6
Tested by hand using a test project deployed using sls.