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

断了今生、忘了曾经 提交于 2019-12-24 13:14:45

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/21475165/nservice-bus-unable-to-set-the-value-for-key-scaleout-usesinglebrokerqueue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!