The Error: Invalid queue path name

Topics: Logging Application Block
Jul 18, 2012 at 5:02 PM

I'm getting this error:

An error occurred in application TestAppDomain: b98d3e5d-3652-47e7-9e30-9338316d2e2b in the Enterprise Library Logging Application Block.Failure while sending log entry to the TraceListeners.The exception that occured was: System.Messaging.MessageQueueException (0x80004005): Invalid queue path name.   at System.Messaging.MessageQueue.ResolveFormatNameFromQueuePath(String queuePath, Boolean throwException)   at System.Messaging.MessageQueue.get_FormatName()
...

 When I'm calling it on the local (the send and receive parts of the Msmq queue are both on the same local), everything is working fine. The error happens when I'm calling the Msmq TraceListener Not on the local computer. 

The path (in the app.config file) is like:

 queuePath="mycomputername\private$\company.integration.common.logging.nontransactional" 

Please, help!

Jul 18, 2012 at 5:09 PM

What if you try:

queuePath="FormatName:DIRECT=OS:mycomputername\private$\company.integration.common.logging.nontransactional"

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Jul 18, 2012 at 5:57 PM

Thank you, Randy, for a quick response!

Cool. It works now but...

now I'm getting another error on the computer with the receive part of the queue. The messages are disappeared from the sender queue part and do not received on the receive queue part:

"Log Name:      ApplicationSource:        Microsoft-Windows-MSMQDate:          7/18/2012 10:02:24 AMEvent ID:      2177Task Category: NoneLevel:         ErrorKeywords:      ClassicUser:          N/AComputer:      mycomp.dev.prvDescription:The Message Queuing service rejects incoming messages when it is unable to check whether the sender is allowed access to the queue for sending messages. In this case, the queue affected is mycomp\private$\integration.common.logging.nontransactional, but note that an event might not be issued every time this problem occurs. To perform this access check, Message Queuing needs access to the TokenGroupsGlobalAndUniversal attribute of the sender's user object. Only users with domain administration permissions can add members to the Windows Authorization Access Group, which is allowed access to the TokenGroupsGlobalAndUniversal attribute, in one of two ways: 1) For best security practice, add only the computer accounts that need access to the TokenGroupsGlobalAndUniversal attribute to the Windows Authorization Access Group. The domain administrator will repeat this operation for other Message Queuing computers that require the permission, manually adding the relevant accounts to the Windows Authorization Access Group. 2) As a less secure practice, add the Authenticated Users group to the Windows Authorization Access group. This grants every authenticated user, including the Message Queuing service on any computer, access to the TokenGroupsGlobalAndUniversal attribute for all users, and requires no further manual administration.Event Xml:<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">  <System>    <Provider Name="Microsoft-Windows-MSMQ" Guid="{ce18af71-5efd-4f5a-9bd5-635e34632f69}" EventSourceName="MSMQ" />    <EventID Qualifiers="49152">2177</EventID>    <Version>0</Version>    <Level>2</Level>    <Task>0</Task>    <Opcode>0</Opcode>    <Keywords>0x80000000000000</Keywords>    <TimeCreated SystemTime="2012-07-18T16:02:24.000000000Z" />    <EventRecordID>75918</EventRecordID>    <Correlation />    <Execution ProcessID="0" ThreadID="0" />    <Channel>Application</Channel>    <Computer>mycomp.dev.prv</Computer>    <Security />  </System>  <EventData>    <Data Name="param1">mycomp\private$\integration.common.logging.nontransactional</Data>  </EventData></Event>

Jul 18, 2012 at 6:13 PM

It sounds like permissions.  Can you try adding permissions as per http://technet.microsoft.com/en-us/library/cc773590(v=ws.10).aspx?

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Jul 18, 2012 at 6:41 PM

Randy,

Thanks a lot for your help!

 

Leonid Ganeline  
[BizTalk MVP]http://geekswithblogs.net/leonidganeline/

Sep 12, 2012 at 10:55 PM

i have a scenario where i have to set the queue path programatically depending on the environments. i want to know how to set the queue path programtically using enterprise library 5.0

Sep 13, 2012 at 12:30 AM

You can use the fluent interface to configure logging programmtically.  For example:

var builder = new ConfigurationSourceBuilder();

builder.ConfigureLogging()
        .WithOptions
            .DoNotRevertImpersonation()
        .LogToCategoryNamed("General")
            .SendTo.Msmq("MSMQ Trace Listener")
            .FormatWith(new FormatterBuilder().BinaryFormatterNamed("BinaryFormatter"))
            .UseQueue(@"FormatName:DIRECT=OS:mycomputername\private$\company.integration.common.logging.nontransactional")
            .WithTransactionType(MessageQueueTransactionType.None)
            .Prioritize(MessagePriority.AboveNormal)
            ;

var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current
    = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Sep 13, 2012 at 12:58 AM

randy,

thank you for the quick response. i am logging the entry as following

public void logger(LogEntry logEntry)

{

logEntry.categories.add("MSMQ");

var container = new UnityContainer().AddNewExtension<EnterpriseLibraryCoreExtension>();
var writer= container.resolve<LogWriter>();
writer.write(logEntry);

can you let me know where i have to use the above code in my logic.

 

thanks once again

sandeep

Sep 13, 2012 at 2:58 AM

randy,

one more question do we still need to put the configuration in app.config/web.config when using fluent interface?

Sep 13, 2012 at 8:28 AM

If you are using the fluent interface then you don't need any file based (app.config or web.config).

If you are using Unity directly then you can configure the container as follows:

var builder = new ConfigurationSourceBuilder();

builder.ConfigureLogging()
        .WithOptions
            .DoNotRevertImpersonation()
        .LogToCategoryNamed("General")
            .SendTo.Msmq("MSMQ Trace Listener")
            .FormatWith(new FormatterBuilder().BinaryFormatterNamed("BinaryFormatter"))
            .UseQueue(@"FormatName:DIRECT=OS:mycomputername\private$\company.integration.common.logging.nontransactional")
            .WithTransactionType(MessageQueueTransactionType.None)
            .Prioritize(MessagePriority.AboveNormal)
            ;

var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);

EnterpriseLibraryCoreExtension coreExtension = new EnterpriseLibraryCoreExtension(configSource);
IUnityContainer container = new UnityContainer();
container.AddExtension(coreExtension);

var logger = container.Resolve<LogWriter>();

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Sep 13, 2012 at 4:18 PM

randy,

thanks a lot for the quick response. i got the code working. i have one more issue, i want my application to log only when a speicific minimum severity is mentioned and i want this value in app.config while using the above code. my question is can i set the minimum severity in the app.config while using fluent interface, if so how

Sep 13, 2012 at 6:14 PM

The easiest way would be to set a value in app.config and feed that into the fluent interface.  For example:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="MinimumSeverity" value="Warning"/>
  </appSettings>
</configuration>

And then read that value in and set it in the fluent interface:

    string minimumSeverity = System.Configuration.ConfigurationManager.AppSettings["MinimumSeverity"];
    System.Diagnostics.SourceLevels minimumSourceLevel;

    if (!Enum.TryParse(minimumSeverity, out minimumSourceLevel))
    {
        minimumSourceLevel = System.Diagnostics.SourceLevels.All;
    }

    string s = @"DIRECT=OS:mycomputername\private$\company.integration.common.logging.nontransactional"; 
    string str = "FormatName:" + "" + s; 
    var builder = new ConfigurationSourceBuilder();
    builder.ConfigureLogging()
        .WithOptions.DoNotRevertImpersonation()
        .LogToCategoryNamed("General")
            .SendTo.Msmq("MSMQ Trace Listener")
            .FormatWith(new FormatterBuilder().BinaryFormatterNamed("BinaryFormatter"))
            .UseQueue(str)
            .WithTransactionType(MessageQueueTransactionType.None)
            .Prioritize(MessagePriority.AboveNormal)
            .SendTo.EventLog("Event Log Listener")
            .FormatWith(new FormatterBuilder().TextFormatterNamed("Text Formatter")
                .UsingTemplate("Message: {message}..."))
            .ToLog("Application")
            .LogToCategoryNamed("Application")
        .LogToCategoryNamed("FlatFile")
            .WithOptions.SetAsDefaultCategory()
            .ToSourceLevels(minimumSourceLevel)
            .SendTo.FlatFile("Flat File Trace Listener")
            .ToFile("trace.log");                    

    var configSource = new DictionaryConfigurationSource(); 
    builder.UpdateConfigurationWithReplace(configSource); 
    EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); 
--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Oct 10, 2012 at 4:04 AM
Edited Oct 10, 2012 at 4:04 AM

randy,

I have one question, is there any way to set the dynamic queue paths and data base connection strings with out using fluent interface. he fluent interface is causing performance issues, i was wondering if i can set the dynamic paths using configuration files.

Oct 10, 2012 at 8:36 AM

I assume you mean dynamically writing/loading configuration files at runtime.  I don't see how that would be much different.  Creating, configuring and replacing the entire container is a relatively heavy operation so should be done sparingly.  You could forgo the fluent interface and interact with the Enterprise Library classes directly -- this would give you the most control but requires more code and testing.  Some of the pertinent classes would be LogWriterImpl, LogSource, MsmqTraceListener.  

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com