Enterprise Library LogEntry object and WCF MSMQIntegrationBinding Problem - Urgent Help Required

Topics: Building and extending application blocks, Logging Application Block
Apr 23, 2009 at 6:46 AM
Hi,

We have the following requirement in our project:

To create a client application in C# which uses the enterprise library 4.1 for logging information. For one of the logging catgeory, the log object is sent to private queue on a machine.
And instead of using the microsoft provided Distributor service to read the message from the queue, we need to have a WCF Service. On starting the service it should monitor the private queue and when a message arrives in the queue using the MSMQ Integration binding Service contract it should trigger a event in the application which reads the message from the queue and shows it on to the screen to the user.

Of the above requirements we have created the client application that logs information into the private queue using enterprise library. We have also created the WCF service.

Problem : The WCF service is able to read the message from the queue and display on the screen only when the client application logs the information in the queue directly without using Enterprise library.

MessageQueue queue = new MessageQueue(@"formatname:DIRECT=OS:.\private$\logqueue");
System.Messaging.Message msg = new System.Messaging.Message(logMessage, new BinaryMessageFormatter());
queue.Send(msg, MessageQueueTransactionType.Automatic);

If the message or information is logged to the queue using MSMQ trace listener of enterprise library then the WCF service tries to read the message from the queue, but does not trigger the event in the application and the message gets lost from the queue.

For logging the message in the queue we are using the Binary formator. Also one of the requirements for the queues is that it should be non-transactional.

Appricate your help in identifying how to make this work ...

Regards
Sameer


Apr 23, 2009 at 8:28 AM
Hi,

Do you have get any exception? What is the formatter that you use when you read the message from the message queue? I tried to do a repro of your scenario, I just created a simple console app which logs using Logging App Block with msmqtracelistener, then I tried reading it from the queue, when read the message from the queue using the BinaryMessageFormatter, it was not able. But when I tried using the XmlMessageFormatter its reads fine. Now, I looked at the source code of the Logging App Block and it seems that when it sends logs to the queue, it uses the XmlMessageFormatter. You can verify this by using XmlMessageFormatter.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Apr 23, 2009 at 9:44 AM
Hi Dudan,

Thanks for your reply.

Actually we are not getting any exception when reading the message from queue. We have tried specifying the serialization format as "XML" and Binary, but with no luck.

It would be nice if you can share your application so that we can have a  look at it. You can send the files on sameer.mallelwar@gmail.com .

Regards
Sameer

Apr 23, 2009 at 4:07 PM
Please refer to this post : http://entlib.codeplex.com/Thread/View.aspx?ThreadId=54098