Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Messenger] Add middleware to stop all workers on exception #35481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Jan 27, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #34414
License MIT
Doc PR will come

This is an alternative to #35453. It will fix #34414 and fix #35360.

framework:
    messenger:
        buses:
            command_bus:
                middleware:
                    - stop_worker_on_exceptions: [['App\Exception\Foo', 'Doctrine\ORM\ORMException']]

If any of these exceptions is thrown when handling a message in "command_bus" we will stop all workers.

You may also be more defensive:

framework:
    messenger:
        buses:
            command_bus:
                middleware:
                    - stop_worker_on_exceptions: [['*']]

This will avoid situation where you have 100 messages on the queue, and when handling message 5 it causes an exception that closes the EntityManager. As a result the other 95 messages will also fail because "The EntityManager is closed."


Drawback of this approach. This will stop ALL workers, even workers in other threads. It will also stop all workers even if the message was handled synchronously.


This is a draft PR, which means that Im not done with the implementation. I want some feedback before I add tests, documentation and possibly trying to fix some of the drawbacks.

@Tobion
Copy link
Contributor

Tobion commented Feb 9, 2020

I like the solution in #35453 much better. Using a middleware for this, requires to change the messenger config. This in turn means you need to regenerate the container and redeploy.

In #34979 it's just an option. So if you realize you often run into problems, you just change an argument of your worker. Done.

@elzozo13
Copy link

elzozo13 commented Feb 9, 2020

I like the solution in #34979 much better. Using a middleware for this, requires to change the messenger config. This in turn means you need to regenerate the container and redeploy.

In #34979 it's just an option. So if you realize you often run into problems, you just change an argument of your worker. Done.

If I read #34979 right, it doesn't solve either #34414 or #35360. Pls. correct me if I'm wrong. Am I missing something?

@Tobion
Copy link
Contributor

Tobion commented Feb 9, 2020

I meant #35453

@Nyholm
Copy link
Member Author

Nyholm commented Feb 22, 2020

Thank you for the review.

@Nyholm Nyholm closed this Feb 22, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If a db error occurs the entity manager is closed for all future messages [Messenger] Add option to stop the worker after a message failed
5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.