简体   繁体   中英

Nservice Bus Endpoint Naming

I am trying to get to grips with NSerivceBus and although it's mostly going smoothly I am struggling to understand how to configure the EndPointName.

So for example, after following a few examples I have managed to come up with the following but any attempt I make to change the EndPoint Name fails.

So the myServer queue is currently what it is named, taken, I think from the namespace here:

  namespace MyServer
{
    class EndPointConfig : IConfigureThisEndpoint, AsA_Server
    {
    }
}

But when i Put [EndpointName("AnotherQueue")] nothing changes (Except it doesnt fill the myServer queue.

I also tried to change the 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();
        }

But again, it didnt work.

I am testing it by looking at mmc and checking the message queuing there.

Lastly I have tried altering the 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>

And still nothing.

Is anyone able to help? I'm still trying to get my head around this (It's a new technology to me) so I apolagise if I have asked this question poorly.

Thanks in advance Lex

Couple things:

I'm not 100% sure, but I don't think you want to use IConfigureThisEndpoint, and AsA_Server if you are hosting in a web application. I believe the configuration code you have in Application_Start is all you need. The other means of configuring is for when you host in the NSB's own process (as a windows service or console).

Try putting DefineEndPointName("AnotherQueue") as the first command after NServiceBus.Configure.With() . This is the way I have it setup and it works, and I believe the order of the commands after With() do matter, and can fail silently (I think this will be addressed in a future release).

Depending on what you are trying to accomplish, you may not need the unicastbus config at all. That is used to define endpoints on the client side--in other words, use it to define endpoints your app wants to talk to.

Finally, use the debug window of your web app as you run it to find clues about what may be going wrong. NSB produces a lot of very useful logging information in debug mode, all of which should be sent to the debug window. It may be that your app doesn't have permissions to create the queue, or something along those lines. Once I figured that bit out, troubleshooting a lot of the "learning curve problems" became much easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM