-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add explicit handler assembly registration mode instead of relying on scanning all assemblies #5595
Comments
We have ExcludeAssemblies at the moment: https://docs.particular.net/nservicebus/hosting/assembly-scanning#exclude-a-list-approach-exclude-specific-assemblies-by-name |
Let's take an .NET core project for example. A minimal ASP.NET Core project contains about 70 assemblies. Typically only a few of them will container handlers, which means that with the Exclude approach you need to scan through all 70 assemblies and invoke the Exclude method for 68 of them. If you have a What I suggest is this: Add a If
If
And let the documentation list which assemblies must be included (today it just says |
Hey @jgauffin, thanks for the feedback so far. We do more than add (and scan) assemblies for handlers though. Also sagas, messages and more. |
The documentation states:
It also states:
That in combination of a method named Why not either just state something like "All NSB assemblies must be included plus your handler and saga assemblies". In my case I did an educated guess. And as a result the callbacks stopped working (NSB gave me the "No handler can be found") which made it hard to back track it back to the assembly loading optimization. And I assume that the kind of error will differ depending on which function you use and which assembly you forget to include. The documentation also states:
and
Well, to improve startup time you want to remove as many assemblies as possible, which means that you will accidentally remove required assemblies ;) No sane developer will manually exclude all .NET core assemblies. |
I think the larger issue here is why you're wanting to exclude assemblies in the first place. The current design is intended for you to not need to do anything, and it just works. The assembly exclusion API is intended to be an escape hatch for a problem, or if you're doing something more advanced like having more than one endpoint hosted in a single process. If the reason you're trying to exclude assemblies is because of startup performance, then I think we should be focusing on why you're seeing bad performance, and fixing that. @jgauffin What sort of startup times are you seeing that has made you start using the exclusion API? I know you've also got a discussion thread about this, and that's why I asked to see more information from when you were profiling it. I'd like to see if there's a way for us to improve the scanning performance. |
The thing is, you have the API, If it should not be used, deprecate it. If the purpose is not to improve startup performance remove that statement from the documentation. I'll do measurements tomorrow, with and without my assembly exclusion. |
I've updated the discuss thread. Nine seconds is a quite large difference. |
I did a quick spike that excludes in a rather blunt and brutforce way the system and microsoft assemblies It cut down the scanning time in half |
We're currently on NServiceBus 4.x trying to upgrade to 7.x and running to the issue where we previously ran This method is much preferred as it's very explicit to what you're pulling in vs. running into a gotcha where a class will be registered automatically and cause unexpected issues. |
Just my two cents on this - I was playing around with NSB in F# and - as always when trying out a new library for the first time - I try it from a script just to get a feel for the library. In this case, I struggled quite a bit because of the assembly scanning as the only real way of locating Message Handlers. I worked around it using the Going another step further would be to turn over control of the instantiation of the values to the caller, so a list of One or both of these would make the product more attractive to F# works (and lowering the barrier to entry). |
Suggestion from Jonas in https://discuss.particular.net/t/request-reply-that-hangs/1622/3
The text was updated successfully, but these errors were encountered: