Skip to content

Conversation

patrickcarlohickman
Copy link
Contributor

PR #56763 added initial support for SQS FIFO and fair queues. However, there are a couple issues with the implementation.

Issues

  1. The extra options are only added if the queue name ends with ".fifo". This means that fair queues are not actually supported, since the MessageGroupId option will only be sent on FIFO queues.

  2. The extra options are only added if a job object is dispatched. If the string notation is used to dispatch to a FIFO queue, the extra options will not be added and the code will throw an exception (ex: Queue::push('ProcessPodcast@handle')).

  3. Depending on how the job is dispatched, the queue name passed into the getQueueableOptions() method may be null. When this is the case, the method will not recognize the queue as a FIFO queue, the extra options will not be added, and the job dispatch will throw an exception.

    • For example, assume the application default queue is a FIFO queue. ProcessPodcast::dispatch($podcast) will attempt to dispatch to the default FIFO queue. However, since the queue name wasn't specified for the job, $queue->push() will be called with a null queue name, which will be passed into the getQueuableOptions() method.
  4. If a FIFO job is dispatched with a delay, the code will throw an exception. FIFO queues do not support per-job delays. Delays are defined at the queue level in AWS. Therefore, FIFO queues do not support the DelaySeconds option and will throw an exception if present.

Assumptions

When resolving item 2, we need to determine a message group id to use since there is no dispatched object to provide one. There are two options:

  1. every string job goes onto the same message group id, or
  2. every string job goes onto a unique message group id.

I chose to put every string job onto the same message group id, using the name of the queue as the message group id to use. I made this assumption so that FIFO processing would maintained for all string jobs if the user is dispatching string jobs. If we used a unique message group id instead, this would not ensure FIFO processing for the dispatched jobs, which is probably not what was intended considering the use of the SQS FIFO queue.

Resolutions

I would have preferred to create separate PRs to address these issues, but they're pretty much all related to the same method, so I just created the one.

I have added tests that highlight the issues and show they've been fixed.

Extra Considerations

I allude to this in one of the comments in the code, but the current implementation will always generate a unique deduplication id if the job does not define the deduplicationId() method. If the user enables content-based deduplication on the queue in AWS, they will not be able to take advantage of this unless they define a deduplicationId() method that returns an empty value. This is not very intuitive, and we may want a more direct solution for this. However, that is not within the scope of this PR.

Please let me know if you need me to make any changes or have any questions. Also, for full disclosure, I am the maintainer of the https://github.com/shiftonelabs/laravel-sqs-fifo-queue package.

@taylorotwell taylorotwell merged commit 66a4cab into laravel:12.x Sep 17, 2025
63 checks passed
@taylorotwell
Copy link
Member

Thanks!

tegos pushed a commit to tegos/laravel-framework that referenced this pull request Sep 28, 2025
* Add tests to ensure that job objects are properly queued on SQS using push or pending dispatch.

* Add tests to ensure that job objects can properly enable SQS fair queues.

* Add a test to ensure that job strings are properly pushed onto SQS FIFO queues.

* Add tests to ensure that job objects are properly pushed onto SQS FIFO queues using push or pending dispatch.

* Add tests to ensure that DelaySeconds are not sent to SQS FIFO queues when delayed.

* Properly handle the message group and deduplication queable options for SQS FIFO and fair queues.

* Ensure DelaySeconds is not sent to SQS FIFO queues.

* Restore normal uuid creation at end of tests.

* formatting

---------

Co-authored-by: Taylor Otwell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants