本文介绍了NService 总线:“无法设置键的值:ScaleOut.UseSingleBrokerQueue."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 nservicebus.structuremap 时遇到这种类型的错误.这是我的代码.

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

EndPointConfig.cs

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.

推荐答案

由于我使用的是 NServiceBus.Host,因此我不需要在您的端点配置中创建总线:

Since I am using NServiceBus.Host, i don't need to create the bus in your endpoint config:

我的初始化变成了这样:由于 AsA_Server 角色是 beign 使用,它已经将启动时的清除队列设置为 false,使用单播总线等.总线将被创建并在所有消息处理程序中通过 DI 可用.

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();
    }
}

更多详情请见:http://particular.net/articles/the-nservicebus-host(部分内置-在配置中)以及http://particular.net/articles/containers

For more details see:http://particular.net/articles/the-nservicebus-host (section built-in configurations) and also http://particular.net/articles/containers

此外,对于订阅存储,建议将 RavenDB 或 NHibernate(sql 存储)用于生产而不是 msmq.

Also, for subscription storage, either RavenDB or NHibernate (sql storage) is recommended for production and not msmq.

希望这会有所帮助,

尼昆杰巴拉尔

这篇关于NService 总线:“无法设置键的值:ScaleOut.UseSingleBrokerQueue."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:35