Recommended way to create multiple NServiceBus publishers in a single application/process?
I'm going to have several publishers that are all logical components of a single "application".
Although I try pretty hard to separate concerns (i.e. there are many independent class libraries making up the domain logic), I'd still much rather have just one application to deploy, debug, etc.
All of the examples I've looked at so far seem to rely on putting the publisher information in the app.config, and it looks like I can only declare one publisher that way.
It looks like I might be able to use the CustomConfigurationSource
method but I feel like I'm missing something far more straightforward and direct.
Is there a simple/recommended way to create multiple publishers (each with a different event type) in a single appli开发者_开发技巧cation, either using the generic host or with self-hosting?
Provided you're following the guidance of each logical publisher publishing different event types where no two logical publishers ever publish the exact same type, you're fine.
Following this enables you to have one or more logical publishers "co-hosted" in a single application process. The fact that they are talking to the exact same physical database table isn't necessarily a problem because they won't have any overlap with each other and they won't step on each others' toes.
As long as you've done the logical separation in code there isn't any problem with putting them into the same physical process and sharing the same physical resources such as queues and databases.
From there, just fire things up using NServiceBus.Host.exe (for Windows hosting) and you're good to go.
精彩评论