Skip to content

Conversation

patrickcarlohickman
Copy link
Contributor

This is a follow up to the previous PR #57187 that extended SQS FIFO and fair queue support to mailables, notifications, and event listeners. This PR adds support for defining a messageGroup method on the job classes instead of requiring the use of the onGroup() method at time of dispatch. See discussion on previous PR starting here.

Summary

Normal jobs, mailables, and notifications are actively dispatched by the user and have the ability to call onGroup() at the time of dispatch. However, event listeners are not dispatched by the user. They are predefined ahead of time (with class methods), and then dispatching the event triggers the listener. There is nowhere for the user to call onGroup() for a class-based event listener.

Due to this, there was an inconsistency where event listeners supported a messageGroup() method on the class, but all the other job types required calling onGroup() at the time of dispatch.

To help add some consistency, this PR adds support for defining a messageGroup() method on the other job types, as well. This also allows the message group logic to remain encapsulated inside of the job and not need to be provided by the dispatching logic.

Notes

  • The messageGroup() method does not take any parameters.

  • The value of the $messageGroup property takes precedence over the messageGroup() method. This allows the dispatcher to still call onGroup() and have that value used instead of the messageGroup() method.

  • For notifications, the new messageGroup() method support is in addition to the existing support for the withMessageGroups($notifiable, $channel) method, which takes the notifiable and channel in as parameters to determine the message group.

Please let me know if you need me to make any changes or have any questions.

@taylorotwell taylorotwell merged commit 446a1a5 into laravel:12.x Oct 17, 2025
68 checks passed
@taylorotwell
Copy link
Member

Thanks a ton!

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