Ordering Custom Behaviors

Is there a way to control what order custom behaviors execute in the pipeline? I’ve built a rate limiting behavior that I would like to ensure runs first in the pipeline, since all of the other custom behaviors are irrelevant if the message is going to be throttled. I read the documentation at https://docs.particular.net/nservicebus/pipeline/manipulate-with-behaviors, but I didn’t see anything there that seemed like it would allow me to force a specific behavior to run first?

Is there a way to do this or some other documentation I should be looking at?

Thanks.

It’s usually best to place the behaviour in the stage either before or after the behaviour that you have a dependency on.

See Steps, Stages and Connectors • NServiceBus • Particular Docs for the list of available stages.

Should that not be possible we provide an API for ordering behaviours within a stage by implementing a RegisterStep mentioned in Customizing Error Handling • NServiceBus • Particular Docs and from the call one of the InsertAfter, InsertAfterIfExists, InsertBefore or InsertBeforeIfExists methods.

Hope this helps!

RegisterStep worked great. Thanks for your help.