[X] I have searched issues to ensure it has not already been reported
Description
Using the setup below, I am able to resolve services in MessageConsumeStarted such as
using (var scope = context.DependencyResolver.CreateScope()) { //Code Here }
If I attempt to use the same code in OnConsumeCompleted or OnConsumeError, I get an error the following error:
System.AggregateException: One or more errors occurred. (Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.)
In my message handlers, I'm injecting my DBContext for EF, so it's important that I'm able register these as scoped. I can't use Transient as I set different parameters that need to be available vi scoped DI down the pipeline.
Create 3 Global Events, MessageConsumeStarted, MessageConsumeCompleted, and MessageConsumeError
Observe dependencies can be resolved in MessageConsumeStarted but not in MessageConsumeCompleted or MessageConsumeError
Expected behavior
All Global Events can resolve dependencies
Actual behavior
In the Global Event Handlers, OnConsumeCompleted or OnConsumeError, Dependancies cannot be resolved.
Using var scope = context.DependencyResolver.CreateScope()or context.DependencyResolver.Resolve<BaseEntity>(); results in the folowwing error:
System.AggregateException: One or more errors occurred. (Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.)
Prerequisites
Description
Using the setup below, I am able to resolve services in MessageConsumeStarted such as
using (var scope = context.DependencyResolver.CreateScope()) { //Code Here }
If I attempt to use the same code in OnConsumeCompleted or OnConsumeError, I get an error the following error:
System.AggregateException: One or more errors occurred. (Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.)
In my message handlers, I'm injecting my DBContext for EF, so it's important that I'm able register these as scoped. I can't use Transient as I set different parameters that need to be available vi scoped DI down the pipeline.
Steps to reproduce
Expected behavior
All Global Events can resolve dependencies
Actual behavior
In the Global Event Handlers, OnConsumeCompleted or OnConsumeError, Dependancies cannot be resolved.
Using var scope =
context.DependencyResolver.CreateScope()
orcontext.DependencyResolver.Resolve<BaseEntity>();
results in the folowwing error:System.AggregateException: One or more errors occurred. (Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.)
KafkaFlow version
3.0.10