Skip to content

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

License

Notifications You must be signed in to change notification settings

NServiceBusExtensions/NServiceBus.HandlerOrdering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NServiceBus.HandlerOrdering

Build status NuGet Status

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.

Contents

Already a Patron? skip past this section

Community backed

It is expected that all developers either become a Patron or have a Tidelift Subscription to use NServiceBusExtensions. Go to licensing FAQ

Sponsors

Support this project by becoming a Sponsor. The company avatar will show up here with a website link. The avatar will also be added to all GitHub repositories under the NServiceBusExtensions organization.

Patrons

Thanks to all the backing developers. Support this project by becoming a patron.

Support via TideLift

Support is available via a Tidelift Subscription.

NuGet package

https://nuget.org/packages/NServiceBus.HandlerOrdering/

Usage

configuration.ApplyInterfaceHandlerOrdering();

snippet source | anchor

Expressing dependencies

MessageHandler1 wants to run after MessageHandler3

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

snippet source | anchor

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

snippet source | anchor

MessageHandler2 wants to run after MessageHandler1

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

snippet source | anchor

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

snippet source | anchor

Resulting execution order

  1. MessageHandler3
  2. MessageHandler1
  3. MessageHandler2

Sample

The sample demonstrates how to use interfaces to express dependencies between handlers.

Configuring to use HandlerOrdering

endpointConfiguration.ApplyInterfaceHandlerOrdering();

snippet source | anchor

Expressing dependencies

MessageHandler1 wants to run after MessageHandler3

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

snippet source | anchor

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

snippet source | anchor

MessageHandler2 wants to run after MessageHandler1

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

snippet source | anchor

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

snippet source | anchor

Resulting execution order

  1. MessageHandler3
  2. MessageHandler1
  3. MessageHandler2

Security contact information

To report a security vulnerability, use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Icon

Icon courtesy of The Noun Project

About

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

Resources

License

Security policy

Stars

Watchers

Forks

Languages