Nservice总线端点命名

Lex*_*ner 2 c# asp.net nservicebus

我试图掌握NSerivceBus,虽然它很顺利,但我很难理解如何配置EndPointName.

因此,例如,在完成以下几个示例之后,我设法提出以下内容,但我所做的任何更改EndPoint名称的尝试都失败了.

所以myServer队列当前是它的名字,我想从这里命名空间:

  namespace MyServer
{
    class EndPointConfig : IConfigureThisEndpoint, AsA_Server
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当我把[EndpointName("AnotherQueue")]没有任何改变时(除了它没有填满myServer队列.

我还尝试更改Global.ASAX:

public static IBus Bus { get; set; }
        void Application_Start(object sender, EventArgs e)
        {
            Bus = NServiceBus.Configure.With()
                .Log4Net()
                .DefaultBuilder()
                .DefineEndpointName("AnotherQueue")
                .XmlSerializer()
                .MsmqTransport()
                    .IsTransactional(false)
                    .PurgeOnStartup(false)
                .UnicastBus()
                    .ImpersonateSender(false)
                .CreateBus()
                .Start();
        }
Run Code Online (Sandbox Code Playgroud)

但同样,它没有用.

我正在通过查看mmc并检查那里排队的消息来测试它.

最后我尝试改变web.config

<configSections>
        <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NserviceBus.Core"/>
        <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
    </configSections>

    <MsmqTransportConfig ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>

    <UnicastBusConfig>
        <MessageEndpointMappings>
            <add Messages="MyMessage" Endpoint="AnotherQueue"></add>
        </MessageEndpointMappings>
    </UnicastBusConfig>
Run Code Online (Sandbox Code Playgroud)

但仍然没有.

有人能帮忙吗?我仍然试图解决这个问题(对我来说这是一项新技术)所以如果我对这个问题提出质疑,我就会开玩笑.

在此先感谢Lex

Phi*_*ler 6

情侣:

我不是百分百肯定,但我认为你不想使用IConfigureThisEndpoint和AsA_Server,如果你在Web应用程序中托管.我相信您在Application_Start中拥有的配置代码就是您所需要的.其他配置方式适用于您在NSB自己的进程中托管(作为Windows服务或控制台).

尝试放入后DefineEndPointName("AnotherQueue")作为第一个命令NServiceBus.Configure.With().这是我设置它的方式并且它可以工作,我相信With()之后命令的顺序很重要,并且可以无声地失败(我认为这将在未来的版本中解决).

根据您要完成的任务,您可能根本不需要单播总线配置.这用于在客户端定义端点- 换句话说,使用它来定义应用程序想要与之通信的端点.

最后,在运行它时使用Web应用程序的调试窗口来查找可能出错的线索.NSB在调试模式下生成许多非常有用的日志信息,所有这些信息都应该发送到调试窗口.可能是您的应用没有创建队列的权限,或者沿着这些行的某些内容.一旦我发现了这一点,对许多"学习曲线问题"进行故障排除变得更加容易.