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?

A pipeline behavior is an implementation of IPipelineBehavior<TRequest, TResponse>
. It represents a similar pattern to filters in ASP.NET MVC/Web API or pipeline behaviors in NServiceBus.
Changes
There are a couple major breaking changes to v3. All of them I’m fairly happy about actually.Messages
There is no distinction between sync, async (cancellable) requests or notifications. You simply implement eitherIRequest
or INotification
.
You must still create the appropriate handler via either IRequestHandler
, IAsyncRequestHandler
, ICancellableAsyncRequestHandler
.
Async
To send a request or publish a notification simply useTask Send(IRequest)
or Task Publish(INotification)
No longer does it have the “Async” convention of appending to the method name. I know this is often debated about this convention. I don’t mind it at all since there are no sync methods.
Behaviors
The new addition is the interfaceIPipelineBehavior<TRequest, TResponse>
This allows you to create implementation(s) that will invoked in the order they are registered with your container (returned from the MultiInstanceFactory
delegate).
The simplest implementation, that does nothing but call the next possible behavior.
You can see how you can use this to create Pre and Post behaviors to create a pipeline.
Pre & Post Processors
Thankfully, these have already been created and built-in to v3.RequestPreProcessorBehavior<TRequest, TResponse>
and RequestPostProcessorBehavior
<TRequest, TResponse>
to the rescue.
These can be used to implementing the appropriate interface of IRequestPreProcess<TRequest,TResponse>
and IRequestPostProcessor<TRequest,TResponse>
Note: Be sure to register your IRequestPreProcess<TRequest,TResponse>
and IRequestPostProcessor<TRequest,TResponse>
as well as RequestPreProcessorBehavior<TRequest, TResponse>
and RequestPostProcessorBehavior
<TRequest, TResponse>
with your container.