Skip to content

Convention-based handlers#8224

Draft
DavidBoike wants to merge 4 commits intocore-10.2from
convention-based-handlers
Draft

Convention-based handlers#8224
DavidBoike wants to merge 4 commits intocore-10.2from
convention-based-handlers

Conversation

@DavidBoike
Copy link
Copy Markdown
Member

Will need to be rebased on top of a general 10.2 branch.

Comment thread nservicebus/handlers/convention-based.md Outdated
Comment thread nservicebus/handlers/convention-based.md Outdated
Comment thread nservicebus/handlers/convention-based.md Outdated
}
}

[HandlerRegistryExtensions(EntryPointName = "SampleProject")]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so glad we added this 😍

Comment thread Snippets/Core/Core_10/Handlers/ConventionBasedHandlers.cs Outdated
Comment thread nservicebus/handlers/convention-based.md Outdated
Comment thread nservicebus/handlers/convention-based.md Outdated
- The hadnler method's second parameter must be an `IMessageHandlerContext`.
- After the first two parameters, any additional parameters must be either a `CancellationToken` or registered in host's `IServiceCollection`.
- The method can be an instance or static method.
- A handler class may contain multiple handler methods, differing by the message type, but these methods become an inseparable unit. It is not possible to register one handler method on a class but not the other.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would inline code demonstrating the convention be helpful to make the text more memorable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the new TLDR content at the top address this? If not, I'm not sure exactly what you mean.

Comment thread nservicebus/handlers/convention-based.md Outdated
Comment thread nservicebus/handlers/convention-based.md Outdated
DavidBoike and others added 2 commits April 30, 2026 14:07
Co-authored-by: Daniel Marbach <daniel.marbach@openplace.net>
Co-authored-by: Andreas Öhlund <andreas.ohlund@particular.net>
@DavidBoike DavidBoike force-pushed the convention-based-handlers branch from 6db75e5 to 02cbba4 Compare April 30, 2026 19:08
@DavidBoike DavidBoike changed the base branch from master to core-10.2 April 30, 2026 19:08
@DavidBoike DavidBoike force-pushed the convention-based-handlers branch from 02cbba4 to fa0a35f Compare April 30, 2026 19:12
- After the first two parameters, any additional parameters must be either a `CancellationToken` or Services registered in the host's `IServiceCollection`.
- It can be an instance or static method.
- A handler class may contain multiple handler methods, differing by the message type, but these methods become an inseparable unit. It is not possible to register one handler method on a class but not the other.
- If multiple handler methods use the same message type as the first parameter, they will all be executed on the same message.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is that accurate then?

- The hadnler method's second parameter must be an `IMessageHandlerContext`.
- After the first two parameters, any additional parameters must be either a `CancellationToken` or registered in host's `IServiceCollection`.
- The method can be an instance or static method.
- A handler class may contain multiple handler methods, differing by the message type, but these methods become an inseparable unit. It is not possible to register one handler method on a class but not the other.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the new TLDR content at the top address this? If not, I'm not sure exactly what you mean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants