Can explain what you are trying to do? Observer events are fired when you save, delete, etc you models. I'm not sure why you would want to queue these as they are lightweight and quick. You can certainly dispatch other events in your observer events e.g. send an email when a model is created that would make sense to queue
Queue observer
Is it possible to queue all observer events?
@d9705996 Yeah, in my scenario I have an external DB that I need to sync whenever a user saves a product. This is tacking a bit of time, so, i dont want my saving process to take that time it takes to sync the external DB. thats the main reason I want to queue these events.
I had a look around the framework code and the events are being fired by this function - i think
I can't see anyway to queue these events. It might make more sense to either remove the sync process from the local save and use something like replication at the database level to manage this or queue the model operation in you controller so the model observer events won't slow the user experience. You could maybe do this by passing the request to a queued job MyModelUpdated::dispatch($request); but this isn't very scalable.
If would look at what you can do to reduce the latency to the external database.
Old topic but maybe useful for someone : you can simply queue a whole observer
class MyObserver implements ShouldQueue {
....
}
(tested in Laravel 10)
Please or to participate in this conversation.