AssemblyScanner().ExcludeTypes() seems to exclude more than requested types?

Using NServiceBus 7.1.7

So I’m trying to do endpoint multi hosting. My project code all live inside the same assembly.

I created two EndpointConfiguration. The configuration calls EnableInstallers() to create the queues.

I also created two classes implementing a bunch of different IHandleMessages<> each (SharedEventHandlers and InstanceEventHandlers in my sample below).

Now I want each endpoint instance to only subscribe to messages from one of these classes. So I do:

        var configuration = new EndpointConfiguration(EndpointName);
        // configuration... // other configs
        configuration.AssemblyScanner().ExcludeTypes(new[] { typeof(InstanceEventHandlers) });
        _sharedEndpoint = await Endpoint.Start(configuration);

        configuration = new EndpointConfiguration(InstanceName);
        // configuration... // other configs
        configuration.AssemblyScanner().ExcludeTypes(new[] { typeof(SharedEventHandlers) });
        _instanceEndpoint = await Endpoint.Start(configuration);

When I do that, none of the queues get created.

If I comment the “ExcludeTypes” line, all queues of both classes get created for both endpoints.

What transport are you using?
Also, from the name SharedEventHandler sounds like those are shared by the both endpoints. Are you sure it should be excluded?

It would help to see the code rather than just a snippet. If you can share a repro via GitHub or similar, could help to troubleshoot it.

I’m using NServiceBus.RabbitMQ 5.1.1

This might be related to the transport because I was currently (trying to) debugging it using the source code on github and I couldn’t put my finger on anything wrong.

I’ll try to create a simple reproducible project and upload it, but it will go up to next Tuesday until I have time. It shouldn’t require much more than what I described to reproduce it.

As for the name, no they shouldn’t share it. I prefer not to go in detail about my architectural design in this post because it’s unrelated, but it’s about having multiple physical instances of a single logical service endpoint.

I managed to find the problem by trying to reproduce it in a separate project.

I was using NServiceBus.CastleWindsor as the DI builder for my project, and was passing the same container for the both endpoints, which is causing it to create the wrong queues.

Creating two separate Castle Windsor container seems to fix the issue.