Pre and Post Processors handled multiple times (version 8)
See original GitHub issueEDIT: Solution from @lilasquared
Am I doing something wrong here? This happens using pre and post processors
public class MediatRInstaller : IInstaller
{
public void InstallServices(IServiceCollection services, IConfiguration configuration)
{
services.AddMediatR(typeof(CreateCustomerCommand).Assembly);
services.AddScoped(typeof(IRequestPostProcessor<,>), typeof(LoggingBehavior<,>));
}
}
public class LoggingBehavior<TRequest, TResponse> : IRequestPostProcessor<TRequest, TResponse>
{
public Task Process(TRequest request, TResponse response, CancellationToken cancellationToken)
{
Log.Information($"Handled {typeof(TRequest).DeclaringType?.Name ?? typeof(TRequest).Name}");
return Task.CompletedTask;
}
}
After one web request:
08 Jan 2020 10:07:06.507 Handled GetCustomersQuery
08 Jan 2020 10:07:00.679 Handled GetCustomersQuery
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Deconfusing Pre- and Post-processing
Figure 3: PostCSS gives us much more possibilities. We can use everything we had with Sass (Variables, Nesting and Mixins), some of them...
Read more >JMeter: Application of Pre-Processor and Post-Processor
Pre and Post Processors execution time isn't included into test reports. If you want to change this behavior you need to use Transaction ......
Read more >Using Post Processor In JMeter (Regular Expression ...
In this tutorial, you will learn to use JMeter Post Processor such as Regular Expression Extractor, BeanShell, JDBC, Boundry Extractor etc.
Read more >Java Preprocessor and Postprocessor
Under Postprocessor, configure one of the following: For Java, you can configure multiple Postprocessors. This is supported for Integration/Orchestration ...
Read more >Pre/Post-Processor Design Patterns
Mendix developers have multiple choices when it comes to implementing pre- / post-processors. This document explores four pre-processor and post ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the AddMediatR method already connects implementations to types closing the pre and post request processors, so you do not need this line
services.AddScoped(typeof(IRequestPostProcessor<,>), typeof(LoggingBehavior<,>));
you only need to register actual pipeline behaviors manually.
in fact, the main wiki (https://github.com/jbogard/MediatR/wiki#aspnet-core) DOES have this link