TargetProcess exceptions in System Log because of MSMQ errors

Posted on Friday, August 16, 2013 by Nicki

I recently started seeing some errors in the TargetProcess System log. Below is one example.

at Tp.Web.Global.ConfigureBusAndStructureMap() in c:\.jenkins\workspace\BuildPackage\Code\Main\Tp.App_Code\Global.asax.cs:line 209at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start() in c:\Projects\TargetProcess\trunk\Code\Libs\NServiceBus\src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 738at NServiceBus.Unicast.UnicastBus.NServiceBus.IStartableBus.Start(Action startupAction) in c:\Projects\TargetProcess\trunk\Code\Libs\NServiceBus\src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 791at NServiceBus.Unicast.UnicastBus.InitializeSelf() in c:\Projects\TargetProcess\trunk\Code\Libs\NServiceBus\src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 810at Tp.Integration.Messages.ServiceBus.Transport.UiPriority.MsmqUiPriorityTransport.ReceiveMessageLater(TransportMessage m) in c:\.jenkins\workspace\BuildPackage\Code\Main\Tp.Integration.Messages\ServiceBus\Transport\UiPriority\MsmqUiPriorityTransport.cs:line 310at Tp.Integration.Messages.ServiceBus.Transport.UiPriority.MsmqUiPriorityTransport.Send(TransportMessage m, String destination) in c:\.jenkins\workspace\BuildPackage\Code\Main\Tp.Integration.Messages\ServiceBus\Transport\UiPriority\MsmqUiPriorityTransport.cs:line 384at System.Messaging.MessageQueue.Send(Object obj, MessageQueueTransactionType transactionType)at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)System.Messaging.MessageQueueException (0x80004005): Insufficient resources to perform operation.GET http://localhost/targetprocess2/2013-08-14 11:14:48,103 [3] ERROR Tp.Web.Global - Failed to configure TP to work with MSMQ because of the reason.

After investigating the cause I found that there were a lot of messages in some TargetProcess queues. To see the queues open Computer Management, expand Services and Applications, expand Message Queueing and click on Private Queues. You'll see a lot of queue names starting with "tp.". In my case queues for bugzilla integration and subversion integration had lots of messages in them and they reached their quota. To purge the queue(s), expand Private Queues, expand the queue you want to purge, right-click on Queue Messages, hover over All Tasks and click Purge. Click Yes if you want to purge the queues.
After purging all the queues with lots of messages I had to recycle the worker process that hosts Target Process, and the error was not logged in the System Log anymore.

C# - How to access a generic typed property

Posted on Thursday, August 15, 2013 by Nicki

My challenge for today was to get the value of generic typed properties from a generic type. Here is the code that worked.

pendingRequest is a generic-typed instance of RequestResponseAsyncResult where the Request and Response properties are generic.

First we have to get the generic type definition:

Type requestType = pendingRequest.GetType().GetGenericTypeDefinition();
Next we get the generic type arguments:
Type[] typeArgs = requestType.GetGenericArguments();
Then we create a generic base type from our generic type:
Type genericType = typeof(RequestResponseAsyncResult<,>);
The next step is to created a generic type according to the type arguments:
Type constructed = genericType.MakeGenericType(typeArgs);
Now we are able to get the property information:
PropertyInfo pireq = pendingRequest.GetType().GetProperty("Request");
PropertyInfo piresp = pendingRequest.GetType().GetProperty("Response");
Finally we can get our properties using reflection:
object request = pireq.GetValue(pendingRequest, null);
object response = piresp.GetValue(pendingRequest, null);