NserviceBus (version 3.2) custom configuration

897 views Asked by At

Newbie needs help here.

I've been going over the custom configuration documentation. However, I'm not able to figure out what is missing, or if I'm on the correct path. I'm trying to custom configure using IWantCustomInitialization to create a message queue on the fly (instead of the App.Config) and send the message to the message queue.

The message class as follows:-

using System;
using NServiceBus;

namespace MyMessage
{
    [Serializable]
    public class EventMessage : ITaskInfo
    {
        public string CustomerName { get; set; }
        public string PrimeKey { get; set; }
        public string JobName { get; set; }
        public Guid JobRunId { get; set; }
    }

    public interface ITaskInfo : IMessage
    {
        string CustomerName { get; set; }
        string PrimeKey { get; set; }
        string JobName { get; set; }
        Guid JobRunId { get; set; }
    }
}

The test app is as follows:-

using System;
using NServiceBus;
using MyMessage;

namespace TestClient
{
    class DontSubscribe : IConfigureThisEndpoint, AsA_Client,
    IWantCustomInitialization
    {
        public void Init()
        {
            Configure.With()
            .DefineEndpointName("customendpoint")
            .Log4Net()
            .XmlSerializer()
            .DefaultBuilder()
            .MsmqTransport()
            .IsTransactional(true)
            .UnicastBus()
            .LoadMessageHandlers()
            .ImpersonateSender(false)
            .DoNotAutoSubscribe()
            .CreateBus().Start();
        }
    }

    public class Program : IWantToRunAtStartup
    {
        public IBus bus { get; set; }

        public void Run()
        {
            Console.WriteLine("Press enter to send a message.");

            while (Console.ReadLine() != null)
            {
                var msg = bus.CreateInstance<EventMessage>();
                msg.JobName = "JobName";
                msg.JobRunId = Guid.NewGuid();
                msg.PrimeKey = "PrimeKey";

                bus.Send("customendpoint", msg);
            }
        }

        public void Stop()
        {

        }

    }
}

And, the App.config is as follows:-

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig"
type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
</configSections>

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

</configuration>

I'm encountering the following error:-

2012-05-24 15:33:10,386 [Worker.10] WARN NServiceBus.Unicast.Transport.Transact ional.TransactionalTransport [(null)] <(null)> - Failed raising 'transport messa ge received' event for message with ID=a7a885c5-2487-4049-9c41-2faa604c5767\214 System.InvalidOperationException: No handlers could be found for message type: M yMessage.ITaskInfo__impl at NServiceBus.Unicast.UnicastBus.HandleTransportMessage(IBuilder childBuilde r, TransportMessage msg) in d:\BuildAgent-01\work\nsb.master20\src\unicast\NServ iceBus.Unicast\UnicastBus.cs:line 1254 at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender, Tra nsportMessageReceivedEventArgs e) in d:\BuildAgent-01\work\nsb.master20\src\unic ast\NServiceBus.Unicast\UnicastBus.cs:line 1171 at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at NServiceBus.Unicast.Transport.Transactional.TransactionalTransport.OnTrans portMessageReceived(TransportMessage msg) in d:\BuildAgent-01\work\nsb.master20\ src\impl\unicast\transport\NServiceBus.Unicast.Transport.Transactional\Transacti onalTransport.cs:line 480 
2012-05-24 15:33:10,386 [Worker.10] WARN NServiceBus.Unicast.Transport.Transact ional.TransactionalTransport [(null)] <(null)> - Failed raising 'transport messa ge received' event for message with ID=a7a885c5-2487-4049-9c41-2faa604c5767\214 System.InvalidOperationException: No handlers could be found for message type: MyMessage.ITaskInfo__impl at NServiceBus.Unicast.UnicastBus.HandleTransportMessage(IBuilder childBuilde r, TransportMessage msg) in d:\BuildAgent-01\work\nsb.master20\src\unicast\NServ iceBus.Unicast\UnicastBus.cs:line 1254 at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender, Tra nsportMessageReceivedEventArgs e) in d:\BuildAgent-01\work\nsb.master20\src\unic ast\NServiceBus.Unicast\UnicastBus.cs:line 1171 at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at NServiceBus.Unicast.Transport.Transactional.TransactionalTransport.OnTrans portMessageReceived(TransportMessage msg) in d:\BuildAgent-01\work\nsb.master20\ src\impl\unicast\transport\NServiceBus.Unicast.Transport.Transactional\Transacti onalTransport.cs:line 480 
2012-05-24 15:33:11,290 [Worker.10] ERROR NServiceBus.Unicast.Transport.Transact ional.TransactionalTransport [(null)] <(null)> - Message has failed the maximum number of times allowed, ID=a7a885c5-2487-4049-9c41-2faa604c5767\214.

Any pointers, suggestions and comments are more than welcome for a newbie like me. Thank you in advance.

1

There are 1 answers

0
Jamez On

I've had issues with this for days now... turned out that I was missing the following:

  • Right Click Properties on your publisher's class library
  • Click the Debug tab
  • Add NServiceBus.Integration to the command line arguments box.

It sorted the issue for me, although I don't know why.