Using MSMQ Distributor Service

Topics: Logging Application Block
Apr 24, 2007 at 9:32 PM
I would like to use the MSMQ distributor service. I have the service up and running on a test server correctly as far as I can tell but I can't seem to get it to work.

I created a private queue on the server running the distributor service. The queue name is 'Logging'. I tried setting the queue path in the MSMQ Listener to the server running the distributor service (TestServer\Private$\Logging). I set the formatter to Binary. I am using a very simple call for now, 'Logger.Write("Test", "Category");' I added a second eventlog trace listener for just to be sure that the configuration file was correct. The trace message is entered into the event log. I am getting an Invalid Queue path exception for the MSMQ, so it's obviously attempting to the MSMQ trace listener. I tried it also using 'Direct=' in front of the path since I found that on a site while trying to research the issue. Same issue.

I have tried to send to the MSMQ service installed on my local machine and nothing seems to happen. I created a queue locally with the same name and set the QueuePath to .\Private$\Logging. Everything else stays the same. Since I don't have anything setup to read the messages sent to MSMQ on my local machine, I would expect that this would show messages queuing up. No messages are appearing in this queue or in any of the other queues (dead letter, etc.). No errors in the event log and nothing to tell me what, if anything, went wrong.

The desired goal is a configuration that looks exactly like Figure 1 from the 'Using the Distributor Service' page in the Enterprise library help. The page does a great job on specifying how to get the distributor service running, but I can't seem to find any information on setting up the clients to consume/use it. Perhaps it is something straight forward enough that none is needed, but it is eluding me...
Apr 25, 2007 at 1:01 AM
Edited Apr 25, 2007 at 1:01 AM
I haven't played with this Trace Listener or MSMQ in a while, but you could try using the FormatName syntax for the queue path, ie:
BTW when using MSMQ, the client and service are completely decoupled, so you should be able to test them independently. If the client is configured correctly (and the service is not running), you should see messages appear on the queue. If the service is configured correctly and running, the messages should disappear from the queue, and if you're really lucky, get logged to the place you intended.

Apr 25, 2007 at 3:09 PM
That did it!

Thanks Tom
Apr 25, 2007 at 9:42 PM
After I got this working, found the following bug with the policy injection application block to audit method calls:

'Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.Logging.TraceLogEntry' in Assembly 'Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.

This only seems to affect the MSMQ listener. I'm still getting the correct logging with the event log listener which is logging the same information.

I marked the class as serializable recompiled and redeployed and it appears to have corrected the problem.
Apr 25, 2007 at 10:34 PM
Good catch. We'll address this in the maintenance release.