0

I'm getting the following error when trying to configure an instance of the bus.

No endpoint name could be generated, please specify your own convention using Configure.DefineEndpointName(...)

Hmm so I need to tell the bus about endpoint message mappings. I normally use the app.config to specify this, and it works fine accept for my WPF app, (I'm no expert with WPF).

It appears the app.config is not being read within my WPF app or something is wrong... My startup code looks like this (which works fine in winforms or console app)

        Bus = Configure.With()
            .AutofacBuilder(container)
            .XmlSerializer()
            .MsmqTransport().IsTransactional(true).PurgeOnStartup(false)
            .UnicastBus().ImpersonateSender(false).LoadMessageHandlers()
            .CreateBus()
            .Start(); 

Any suggestions...

Ultimately I would like the message to endpoint mappings stored centrally so that all desktop apps could read this on startup ie. central DB that all clients have access to. An example of how to config the bus this way would be appreciated.

CRG
  • 677
  • 1
  • 7
  • 16

2 Answers2

3

Just to add to the accepted answer above: the order in which you call the methods is important. In my case I couldn't get DefineEndpointName() to work unless it was directly after Configure.With()

      Bus = Configure.With()
            .DefineEndpointName("WPFSubscriber")
            .DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("MyMessages"))
            .Log4Net()
            .DefaultBuilder()
            .XmlSerializer()
            .MsmqTransport()
            .IsTransactional(true)
            .PurgeOnStartup(false)
            .UnicastBus().
            ImpersonateSender(false)
            .LoadMessageHandlers()
            .CreateBus()
            .Start();
1

Per the error, just add that to your initialization:

  Bus = Configure.With()
        .AutofacBuilder(container)
        .DefineEndpointName("ENDPOINTNAME")
        .XmlSerializer()
        .MsmqTransport().IsTransactional(true).PurgeOnStartup(false)
        .UnicastBus().ImpersonateSender(false).LoadMessageHandlers()
        .CreateBus()
        .Start();

This will also become your input queue name.

Adam Fyles
  • 6,030
  • 1
  • 23
  • 29
  • Thanks, I should have mentioned that I tried that in my post. This has got me baffled. I've created 3 simple test apps, console, winforms and WPF. The WPF app will not start the bus. The configuration is identical for the other 2 apps and the bus starts and send commands to the endpoint as expected. What is unique with a WPF app and configuring an instance of NServiceBus? Thanks again Adam! – CRG May 09 '12 at 22:03
  • My mistake, I stupidly configured the endpoint names the same. Classic cut & paste error. Where as the console and winforms apps use the default endpoint naming convention - namespace. – CRG May 15 '12 at 22:47