jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
10.91k stars 1.16k forks source link

pipeline behaviour calling scoped object is loosing its state #973

Closed mweel1 closed 6 months ago

mweel1 commented 8 months ago

Basically have this use case.

A scoped class takes gets actions addd to a list during various processes in MediatR handlers. A pipleine behaviour calles the Run() method of the scoped class. The run method of the scoped class takes the list and runs the actions

The problem is when I call this scoped class from a MediatR pipeline the state of the object is always empty.

Here is how I add "state" object.

builder.Services.AddScoped<IntegrationEventService, IntegrationEventService>();

Here is how I add my behaviour

builder.Services.AddTransient(typeof(IPipelineBehavior<,>), typeof(IntegrationBehaviour<,>));

I tried switching the pipeline to scoped, but that didn't work either.

Basically I am trying to add a bunch of domain events and then have those get triggered in a queue once the application layer has done all its work.

Any help would be appreciate, and thank you in advance.

github-actions[bot] commented 6 months ago

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.

github-actions[bot] commented 6 months ago

This issue was closed because it has been stalled for 14 days with no activity.