NService Bus : "Unable to set the value for key: ScaleOut.UseSingleBrokerQueue."

StackOverflow https://stackoverflow.com/questions/21475165

  •  05-10-2022
  •  | 
  •  

Question

I got this type of error when using nservicebus.structuremap. This is my code.

EndPointConfig.cs

namespace NSBus.Server
{
using NServiceBus;

/*
    This class configures this endpoint as a Server. More information about how to configure the NServiceBus host
    can be found here: http://particular.net/articles/the-nservicebus-host
*/
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, UsingTransport<Msmq>, IWantCustomInitialization
{
    public static IBus Bus { get; private set; }

    public void Init()
    {
        ConfigureIocTool();
    }

    private static void ConfigureIocTool()
    {
        var container = new Container(y => y.Scan(scan =>
        {
            scan.TheCallingAssembly();
            scan.AssemblyContainingType<SanelibRegistry>();
            scan.AssemblyContainingType<CommonRegistry>();
            scan.AssemblyContainingType<CoreRegistry>();
            scan.WithDefaultConventions();
            scan.LookForRegistries();
        }));

        Bus = Configure.With()
            .StructureMapBuilder(container)
            .MsmqSubscriptionStorage()
            .PurgeOnStartup(false)
            .UnicastBus()
            .ImpersonateSender(false)
            .CreateBus()
            .Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());           
    }    
}

}

this code running successfully but i got error after some time.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top