Handler Ordering

Project Hosting
NuGet Package NServiceBus.HandlerOrdering (2-pre) | License
This is a community run project. License and support are independent of Particular Software.
Target NServiceBus Version: 7.x
This page targets a pre-release version and is subject to change prior to the final release.

This extension allows a more expressive way to Order Handlers.

HandlerOrdering allows the dependency between handlers to be expressed via interfaces and the resulting order is derived at runtime.

Configuring to use HandlerOrdering

endpointConfiguration.ApplyInterfaceHandlerOrdering();

Expressing dependencies

MessageHandler1 wants to run after MessageHandler3

public class MessageHandler1 :
    IHandleMessages<MyMessage>,
    IWantToRunAfter<MessageHandler3>
{

MessageHandler2 wants to run after MessageHandler1

public class MessageHandler2 :
    IHandleMessages<MyMessage>,
    IWantToRunAfter<MessageHandler1>
{

Resulting execution order

  1. MessageHandler3
  2. MessageHandler1
  3. MessageHandler2

Samples


Last modified