Home > Net >  Can I abort MessageEvent in Symfony from one of the attached listeners?
Can I abort MessageEvent in Symfony from one of the attached listeners?

Time:12-05

Is it possible to prevent sending a message from one of the listeners attached for MessageEvent? In the specific case I have a listener that filters the recipients. There is a black list and it is possible the message to remain without recipients - in this case my app fails with error app.ERROR: An envelope must have at least one recipient.

CodePudding user response:

You should be able to throw an UnrecoverableMessageHandlingException when you detect that the message has no more recipients, and so the message will not be retried and it will be aborted. You may have to catch that in your own code to discard it, but it would be under your control.

  • Related