Using the Distributor Service

Topics: Logging Application Block
Feb 4, 2008 at 4:11 PM
I have deployed the distributor service on a remote machine, and successfully installed and started the "Enterprise Library Distributor Service".
From Microsoft's documenation, they state that the distributor service requires that all log entries be formatted using the BinaryLogFormatter class.
On the client side, I configured the catagory I created as "Test", to use an Msmq TraceListener, and this listener
uses a Binary Formatter.

On the remote machine, I configure the MsmqDistributor.exe.config file to also have a catagory called "Test" to use an Msmq TraceListener, and this listener
also uses a Binary Formatter.

I can send a message to the remote machine, but the message remains in the queue, in fact sometimes 2 messages show, and other times just 1 message shows
in the queue. But I only sent the one message.

What happens next, how do I have the distributor service remove the message from the queue, and to write the message out as text
to a file? Do I need a flatFile TraceListener on both the client side and the service side?

Feb 4, 2008 at 7:13 PM
The Microsoft documentation is very general, I have read the section about the distributor service 4 times over, and I they almost act like by some
magic, that the message in the queue gets taken off the queue and sent to another source. So to make that happen, I created two catagories, one
being a catagory with the mandatory Msmq TraceListener using a Binary Formatter, and another catagory with a FlatFile TraceListener.

I reproduced those catagories, careful to use the exact same names of those catagories, on the server side config file.

The result is, the message never gets off the darn queue, and the flat file grows extremely fast and keeps growing!

Is Enterprise Library 3.1 working the way it should, because this makes no sense at all.

Where are all the examples for msmq trace listeners? There are none. I mean straight-forward basic steps, in
a C# solution.
Feb 6, 2008 at 9:12 AM
Hi Steve -

Sorry to hear you're having problems. Did you modify the config file for the Msmq Distributor Service to specify the name of the queue you want it to pull messages from? There is a sample in the bin\debug folder for the MsmqDistributor in the source, but the required section should look something like this:
		serviceName="Enterprise Library Distributor Service" />
The standard approach for logging over MSMQ is to configure the client to send all messages to the MSMQ Listener (using the "All Events" special source), and then configure the MSMQ Distributor to route the events to different TraceListeners based on their categories.

Hope this helps
Feb 6, 2008 at 3:38 PM
I named the queue log_test and modified the config file (called MsmqDistributor.exe.config ) using the stand-alone configuration editor
to use that queue name, as I did with the client.

I'll try the All Events special source change you mention and see what happens.
Feb 6, 2008 at 3:45 PM
Here is my client code that calls Logger.Write:

void writeToTextFile(string message)
LogEntry logEntry = new LogEntry();
logEntry.Message = message;


catch (Exception e)
string s = e.Message;
int k = 5;
Feb 6, 2008 at 3:50 PM
I just ran a test, from my last post you can see I don't use catagories anymore.
I now only have the Msmq TraceListener under Special Sources\All Events, so no need for catagories?

I sent a text message, it never made it to the queue, so the distributor service did nothing.

Now I am confused.
Feb 12, 2008 at 3:07 PM
Anyone have an idea about this?