mediatr

Mediatr - Where is the right place to invalidate/update cache

我的未来我决定 提交于 2019-12-11 01:29:58
问题 This question stems from this other question I had asked about too many interfaces, QCRS and Mediatr library (request/response) Mediatr: reducing number of DI'ed objects I have created bunch of commands and queries and I have bunch of behaviors and one of them being is a Cache behaviour that for every query, cache is checked for the value before the query is actually executed against the db. So far this is working great, but the delima comes in when I have an UpdateSomethingCommand, once I

Autofac, MediatR & multiple DLL projects

前提是你 提交于 2019-12-10 16:13:17
问题 I have several (eventually 100+) small DLL projects all based on MediatR. This means that the interfaces in use are just the IMediatR interfaces ( IRequest<TResult>, IRequestHandler<IRequest<TResult>, TResult> ). Since a lot of these do not have a UI and are called via orchestration from another DLL I was thinking I could create an Autofac Container project (DLL), register all the micro-services, then resolve what I need at runtime in another app that consumes my container. So far, so good.

DDD: Referencing MediatR interface from the domain project

爷,独闯天下 提交于 2019-12-09 05:45:12
问题 I'm just getting started with DDD. I'm putting domain events into a CQRS application and I'm stumbling on a fundamental task: How to use the MediatR.INotification marker interface within the domain project without creating a domain dependency on infrastructure. My solution is organized in four projects as follows: MyApp.Domain - Domain events - Aggregates - Interfaces (IRepository, etc), etc. MyApp.ApplicationServices - Commands - Command Handlers, etc. MyApp.Infrastructure - Repository -

Mediatr Scope problems

此生再无相见时 提交于 2019-12-07 15:15:22
问题 I am using Mediatr to handle messages from a queue. I can get a simple example to work. However I have run into problems when I try to inject an object into my handler public class MessageCommandHandler : IRequestHandler<MessageCommand, bool> { private IMyDependency myDependency; public MessageCommandHandler(IMyDependency myDependency) { this.myDependency = myDependency; } public Task<bool> Handle(MessageCommand request, CancellationToken cancellationToken) { return Task.FromResult(true); } }

Handling errors/exceptions in a mediator pipeline using CQRS?

丶灬走出姿态 提交于 2019-12-07 02:26:54
问题 I'm trying to follow this post by Jimmy Bogard to implement a mediator pipeline so I can use pre/post request handlers to do some work. From the comments on that article I come to this github gist. I don't quite understand how to hook all of this up yet, so here is my first go. FYI - I'm using Autofac for DI and Web Api 2. Following CQRS, here is a query. public class GetAccountRequest : IAsyncRequest<GetAccountResponse> { public int Id { get; set; } } //try using fluent validation public

Handling errors/exceptions in a mediator pipeline using CQRS?

筅森魡賤 提交于 2019-12-05 06:17:46
I'm trying to follow this post by Jimmy Bogard to implement a mediator pipeline so I can use pre/post request handlers to do some work. From the comments on that article I come to this github gist . I don't quite understand how to hook all of this up yet, so here is my first go. FYI - I'm using Autofac for DI and Web Api 2. Following CQRS, here is a query. public class GetAccountRequest : IAsyncRequest<GetAccountResponse> { public int Id { get; set; } } //try using fluent validation public class GetAccountRequestValidationHandler : AbstractValidator<GetAccountRequest>, IAsyncPreRequestHandler

DDD: Referencing MediatR interface from the domain project

爱⌒轻易说出口 提交于 2019-12-03 06:57:44
I'm just getting started with DDD. I'm putting domain events into a CQRS application and I'm stumbling on a fundamental task: How to use the MediatR.INotification marker interface within the domain project without creating a domain dependency on infrastructure. My solution is organized in four projects as follows: MyApp.Domain - Domain events - Aggregates - Interfaces (IRepository, etc), etc. MyApp.ApplicationServices - Commands - Command Handlers, etc. MyApp.Infrastructure - Repository - Emailer, etc. MyApp.Web - Startup - MediatR NuGet packages and DI here - UI, etc. I currently have the

Add validation to a MediatR behavior pipeline?

假如想象 提交于 2019-12-03 06:57:14
问题 I'm using ASP.NET Core, the built-in container, and MediatR 3 which supports "behavior" pipelines: public class MyRequest : IRequest<string> { // ... } public class MyRequestHandler : IRequestHandler<MyRequest, string> { public string Handle(MyRequest message) { return "Hello!"; } } public class MyPipeline<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> { public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next) { var response = await next();

Add validation to a MediatR behavior pipeline?

隐身守侯 提交于 2019-12-02 21:35:46
I'm using ASP.NET Core, the built-in container, and MediatR 3 which supports "behavior" pipelines : public class MyRequest : IRequest<string> { // ... } public class MyRequestHandler : IRequestHandler<MyRequest, string> { public string Handle(MyRequest message) { return "Hello!"; } } public class MyPipeline<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> { public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next) { var response = await next(); return response; } } // in `Startup.ConfigureServices()`: services.AddTransient(typeof