Since I am using NServiceBus.Host, i don't need to create the bus in your endpoint config:
my initialization becomes something like this: Since the AsA_Server role is beign used, it already will set the purge queue on startup to false, use unicast bus, etc. The bus will be created and will be available via DI in all the message handlers.
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, UsingTransport<Msmq>, IWantCustomInitialization
{
public void Init()
{
var container = new Container(y => y.Scan(scan =>
{
scan.TheCallingAssembly();
scan.AssemblyContainingType<SanelibRegistry>();
scan.AssemblyContainingType<CommonRegistry>();
scan.AssemblyContainingType<CoreRegistry>();
scan.WithDefaultConventions();
scan.LookForRegistries();
}));
Configure.With()
.StructureMapBuilder(container)
.MsmqSubscriptionStorage();
}
}
For more details see: http://particular.net/articles/the-nservicebus-host (section built-in configurations) and also http://particular.net/articles/containers
Also, for subscription storage, either RavenDB or NHibernate (sql storage) is recommended for production and not msmq.
Hope this helps,
Nikunj Balar