I am new to NServiceBus and am trying to develop a publisher and a separate subscriber (Im using v3.2.0.0) that still works fine - both the publisher and the subscriber work in NServiceBus Host. My messages are all published normally, but with interruptions they are not picked up by the subscriber, while the publisher displays the following error:
2012-09-05 14:27:37,491 [Worker.6] WARN NServiceBus.Unicast.UnicastBus [(null)] <(null)> - No handlers could be found for message type: MyNamespace.MyMessage
This warning is not displayed for all messages, so if I continue to post a message after the message, I see that half of them display the message and therefore are not selected by the subscriber, although they all appear in the MSMQ queue.
I admit that I'm struggling to deal with this, so some of my codes may still be complete garbage!
I post to the NSB as follows: posting is one of several different types that I have defined:
private void Publish<T>(T message)
{
var myBus = Configure.Instance.Builder.Build<IBus>();
myBus.Publish(message);
}
The publisher's endpointConfig is as follows:
[EndpointName("MyQueue")]
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
public void Init()
{
Configure.With()
.DefaultBuilder()
.MsmqSubscriptionStorage()
.DisableTimeoutManager()
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("MyNamespace"));
}
}
On the subscriber side, I have the following EndpointConfig:
[EndpointName("MyQueue")]
public class EndPointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
public void Init()
{
Configure.With()
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("MyNamespace"));
}
}
With EventMessageHandler as follows:
public class EventMessageHandler : IEvent, IHandleMessages<IMyMessage>
{
public void Handle(IMyMessage message)
{
Console.WriteLine(string.Format("Subscriber 1 received EventMessage with Id {0}.", message.Id));
}
}
Subscribers app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
</configSections>
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MyNamespace" Endpoint="MyQueue" />
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>