jolicode / jolicode/elastically
IndexationRequest dispatched by async message handler are not handled by IndexationRequestSpoolSubscriber
- Dominant language
- PHP
- Stars
- 257
- Forks
- 43
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
Hi,
I'm working with `jolicode/elastically` and `symfony/messenger` and I'm facing a use case that seems to be not handled by this bundle.
I'm using a Doctrine subscriber to dispatch `IndexationRequest` for each indexed entity being persisted or updated.
As recommended in the documentation, i'm using [this configuration](https://github.com/jolicode/elastically?tab=readme-ov-file#grouping-indexationrequest-in-a-spool) to dispatch `IndexationRequest` in a memory queue, then group them in a `MultipleIndexationRequest` message thanks to `IndexationRequestSpoolSubscriber`.
I also added the `console.event_subscriber` tag to the `IndexationRequestSpoolSubscriber` service in order to flush index messages at console terminate event as I have many commands creating or updating entities.
But I have a third case that seems not handled by the bundle. In my application, I can create or update entities in async message handler (messages handled by `messenger:consume` workers), so several `IndexationRequest` can be dispatched by the handler. These `IndexationRequest` message stay the memory queue without being flushed by `IndexationRequestSpoolSubscriber` as it subscribes only to kernel and console event, but not to worker event.
I create my own subscriber to listen `WorkerMessageHandledEvent` that is dispatched when a worker handle successfully an async message.
What do you thing about adding this kind of listener to your `IndexationRequestSpoolSubscriber` ?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.