Middleware in JustSaying is an extensibility feature that provides a way to add your own code around handlers to add things like custom logging, exactly once handling, or de-duplication.
There are two middlewares that are always added to the message handling pipeline:
The handler invocation middleware is always the innermost middleware in a pipeline, and is responsible for resolving a handler and calling it.
The stopwatch middleware wraps the handler invocation one, and ensures that the
IMessageMonitor.HandlerExecutionTimemethod is called correctly.
These defaults cannot currently be removed, but you can add additional middleware around them.
This will produce the following pipeline, where before/after refer to when code executes before or after the call to the
Before - MyMiddleware Before - ExactlyOnceMiddleware Before - StopwatchMiddleware Before - HandlerInvocationMiddleware After - HandlerInvocationMiddleware After - StopwatchMiddleware After - ExactlyOnceMiddleware After - MyMiddleware