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
ShouldBeUnique doesn't work with event listeners #36632
Comments
|
Same is true for Notifications that can implement ShouldQueue but doesn't work with ShouldBeUnique which would be very convenient. |
Hi, I know this reply is more than a year old but I wanted to ask what do you mean by
In both cases it still create 3 of the same jobs. So how does this |
Was this "enhancement" ever addressed? It seems like if a listener implements the ShouldQueue interface, all the standard queueable interface options should be available, an error should be thrown when implemented on a component that isn't supported, or it should minimally be in the documentation that the shouldbeUnqiue interface doesn't work on listeners. I'm happy to submit a PR for an update to documentation, but won't spend the time if there's any intention of adding support for ShouldBeUnique inside listeners. Thanks! |
Description:
Event listeners are always getting added to the queue even with the presence of
ShouldBeUnique
interface, anduniqueId
anduniqueFor
methods or properties.I have done the same implementation for a
Job
and worked as expected.Steps To Reproduce:
EventServiceProvider $listen
array.ShouldBeUnique
to the event listener.uniqueId
anduniqueFor
methods or properties.uniqueId
value should be hardcoded (say:123
) for the sake of this bug.UserRegistered::dispatch($userId)
)jobs
table and you will see many rows of the same dispatched event.Job
, it creates only 1 job in thejobs
table, and also checked Redis cache and found that there's alaravel_unique_job:App\\Jobs\\TestJob
key which goes away when I run the queue workerphp artisan queue:work
Let me know if you need more details.
The text was updated successfully, but these errors were encountered: