-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Question] DbContextPooling issue with INotifications when publish is executed #1003
Comments
What's wrong with the handler being a transient exactly? |
The particular reason here is for this point. Context pooling works by reusing the same context instance across requests; this means that it's effectively registered as a Singleton, and the same instance is reused across multiple requests (or DI scopes). This means that special care must be taken when the context involves any state that may change between requests. In A DDD structure for domain events we usually have some sequence like this.
Looking on this sequence the issue happens because we've the following on DI
What were the issues we were having?
Turning into the core question There's some possible impact if we choose the path of trying to use scoped instead of transient for those calls? |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
Issue
We're having an issue with INotification event for domain events. The thing is that we were trying to use DbContextPooling but it seems that this throw an exception because a captive dependency https://blog.ploeh.dk/2014/06/02/captive-dependency/
App structure
Possible solution
We were thinking to resolve this registering the INotification on hand as a scoped service.
Possible impacts
You know if there could be some extra impact on this possible solution?
The text was updated successfully, but these errors were encountered: