Skip to content

dvdstelt/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 become a Patron to use any of these libraries. Go to licensing FAQ

Sponsors

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

Patrons

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

Usage

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

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

Release Notes

See closed milestones.

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

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%