Closed rodnaph closed 6 months ago
Hello,
by default, test transports "intercept" messages, and do not dispatch them until process()
is called.
This can be disabled in the config: https://github.com/zenstruck/messenger-test/?tab=readme-ov-file#unblock-mode
don't you have this special config ?intercept=false
added to your test transport?
by default, test transports "intercept" messages, and do not dispatch them until
process()
is called. This can be disabled in the config: https://github.com/zenstruck/messenger-test/?tab=readme-ov-file#unblock-mode
That's correct, my transport is set to intercept messages. So...
Anyway, I think my understanding of the architecture of dispatching and sending to transports perhaps isn't good enough to explain the issue, I'll close this but thanks for your time.
Hey @rodnaph
I really don't understand how this could happend, unless the transport used by the listener is not the same than the one which handles the original message.
If you can provide a reproducer, I may help you find the problem
When processing messages on the test transport available/new messages are processed immediately. I'm running into an issue where I have a Doctrine
postFlush
listener which dispatches a message to the bus, and as the resultant message is processed right away it's causing UnitOfWork to be re-entered resulting in an exception (because this is not expected by Doctrine -"Making changes to entities and calling EntityManager::flush() from within event handlers dispatched by EntityManager::flush() itself is strongly discouraged, and might be deprecated and eventually prevented in the future."
).Here is a sample callstack...
I tried calling
process(1)
, thinking it would stop the message dispatched by the listener being processed, but theStopWorkerOnMessageLimitListener
doesn't seem to have been called to increase the message count as the first message is still processing.I don't really want to disable my listener, as this is a functional test and I want to assert/exercise it's functionality. I'm not sure what expected behaviour is here, if there are any issues, but just wondering if you have any advice around it.
Any advice appreciated, thanks.