Sponsor: Using RabbitMQ or Azure Service Bus in your .NET systems? Well, you could just use their SDKs and roll your own serialization, routing, outbox, retries, and telemetry. I mean, seriously, how hard could it be?
You’ve run into it. MediatR throwing an InvalidOperationException when you didn’t have a matching handler for a request. There’s a fairly simple solution to prevent this: Find MediatR Requests without Handlers.
So here’s some quick code you can throw in a unit test to verify you don’t have any missing handlers.
Find MediatR Requests without Handlers
The above code uses reflection to get all theIRequest<>, RequestHandler<> and RequestHandler<,>. Also worth mentioning it leverages Autofac for the IsClosedTypeOf method in the linq query.