Replies: 1 comment 1 reply
-
Update on this : I think the code should be in protected function shouldDispatchJob(): bool
{
/** @var \Spatie\EventSourcing\EventHandlers\EventHandlerCollection $eventHandlers */
$eventHandlers = Projectionist::allEventHandlers()
->filter(fn (EventHandler $eventHandler) => in_array($this->event_class, $eventHandler->handles(), true));
return $eventHandlers->asyncEventHandlers()->count() > 0;
} I am going to try this locally and see if this works or the current behavior is there for a reason which I am missing. What do you guys think? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have an interesting case in our project. We are using laravel-event-sourcing package(Amazing package and we love it).
We observed that all of our events are getting queued. So we tried to debug to find the trace where it's happening. If we understand it correctly, in the
StoredEvent
class, the methodshouldDispatchJob
returns a boolean if the job should be dispatched or not.In the
shouldDispatchJob
method, it gets all allEventHandlers and checks if there is a projector or reactor which implements ShouldQueue. If the count is greater than 0, then this event handling needs to be queued.However, as it is getting all event handlers instead of getting the ones which listen to current event. There might be a handler which does not handle current event but it is queued.
Is this expected behavior?
To sum it up : We were expecting that a projector or reactor will only be queued if we implement
ShouldQueue
interface. However, as per theshouldDispatchJob
method.. If there is any handler in the system which is queued, it will queue all the handlers?Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions