In nservicebus v6, in order to define a handler for a message, one just needs to create a class that implements the IHandleMessages<T>
interface. That's it. I don't need the register this handler type via a method in my endpoint or anything of the sort.
I assume the framework uses reflection to find all implementations of the IHandleMessages interface. Is this true? Can I programmatically add/remove handlers at runtime?
NServiceBus scans assemblies for implementations and there is some control over this. See https://docs.particular.net/nservicebus/hosting/assembly-scanning
It may also help to understand how they use publish-subscribe mechanics. The precise implementation will vary depending on your transport.
Where I work, we use SQL Server as our transport and all subscriptions to events are simply in a table in the NServiceBus database.
Read more about it in their docs:
https://docs.particular.net/nservicebus/messaging/publish-subscribe/
and more on auto subcriptions:
https://docs.particular.net/nservicebus/messaging/publish-subscribe/controlling-what-is-subscribed