IndexationRequest dispatched by async message handler are not handled by IndexationRequestSpoolSubscriber
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 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 ?
Hello! Thanks for this nice issue.
What do you thing about adding this kind of listener to your IndexationRequestSpoolSubscriber ?
I'm 💯 for this, that's a very legitimate use-case.
Would you like to submit a PR?
Hi @damienalexandre, I can definitely submit a PR. Stay tuned.