tags:

views:

104

answers:

1

I'm a bit perplexed by an issue I'm getting on a particular deployment, but not on my build machine. This is a web application that is receiving NServiceBus events to keep a persistent view model updated. There are events waiting in the services incoming MSMQ, so the subscription seems to be working correctly, but the application isn't processing them. The output I'm getting is shown below. Sorry for the mass of text; the summary is that the logs point to UnicastBus.Address being Nothing at runtime. Perhaps something is missing in my configuration.

Here are the logs:

[Worker.11] INFO NServiceBus.Unicast.UnicastBus [(null)] -
Common.Users.WebApp.DevTest initialized.
[10] INFO NServiceBus.Unicast.UnicastBus [(null)] - Subscribing to
Common.Users.Messages.Events.IAllUsersPublished, Common.Users.Messages,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null at publisher queue
Common.Users.MessageHandlers.DevTest
[10] INFO NServiceBus.Unicast.UnicastBus [(null)] - Subscribing to
Common.Users.Messages.Events.IAllUsersPublished, Common.Users.Messages,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null at publisher queue
Common.Users.MessageHandlers.DevTest
INFO NServiceBus.Unicast.UnicastBus [(null)] - Common.Users.WebApp.DevTest
initialized.
WARN NServiceBus.Unicast.Transport.Msmq.MsmqTransport [(null)] - Failed raising
'transport message received' event for message with
ID=537591b0-20e2-4ab9-aabc-b635c3d0e23c\3997
System.ArgumentNullException: Value cannot be null.
Parameter name: value
at System.String.IndexOf(String value, Int32 startIndex, Int32 count,
StringComparison comparisonType)
at NServiceBus.Unicast.UnicastBus.IsInitializationMessage(TransportMessage
msg) in
d:\code\nservicebus-src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 1211
at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender,
TransportMessageReceivedEventArgs e) in
d:\code\nservicebus-src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 1056
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at
NServiceBus.Unicast.Transport.Msmq.MsmqTransport.OnTransportMessageReceived(Tran\
sportMessage msg) in
d:\code\nservicebus-src\src\impl\unicast\NServiceBus.Unicast.Msmq\MsmqTransport.\
cs:line 400

This last entry repeats for every message in the queue; the queue messages remain in the queue.

So I checked out the source code IsInitializationMessage; here is the throwing code:

private bool IsInitializationMessage(TransportMessage msg)
{
if (msg.ReturnAddress == null)
return false;

if (!msg.ReturnAddress.Contains(Address)) <<< THROWS
return false;

So it appears that UnicastBus.Address is Nothing. Not sure why this would be; here are the NServiceBus configurations:

<MsmqTransportConfig
InputQueue="Common.Users.WebApp.DevTest"
NumberOfWorkerThreads="1"
MaxRetries="5"
ErrorQueue="Common.Users.WebApp.DevTest.Errors" />

<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Common.Users.Messages"
Endpoint="Common.Users.MessageHandlers.DevTest" />
</MessageEndpointMappings>
</UnicastBusConfig>

On Application_Start I'm using the following code to get NServiceBus started:

Dim bus = NServiceBus.Configure.WithWeb() _
.Log4Net() _
.StructureMapBuilder() _
.XmlSerializer() _
.MsmqTransport() _
.UnicastBus().LoadMessageHandlers() _
.CreateBus()
bus.Start()
A: 

I changed the identity that the web application's app pool was using from defaultapppool to NETWORK SERVICE. On next startup the web app reported the same error. It restarted again an hour later and the problem went away and the messages were all successfully processed. I don't know if the identity change fixed it, or if there was some other change that I'm not aware of. If it happens again or I learn more I'll try to post it here.

pettys