Solved

accessing public message queues

Posted on 2006-11-08
7
730 Views
Last Modified: 2007-12-19
Hello,
I am using message queues in C# asp.net 1.1.  I create a public message queue and on subsequent execution of the code, I check if the queue exists. If it does, I don't want to create it again. The queue gets created successfully, but the problem is MessageQueue.Exists method or GetPublicQueuesByMachine method can't find this queue once it is created, so the control goes to the 'create' statement again and it fails by giving this error:

System.Messaging.MessageQueueException: Queue with the specified path name is already registered in the DS.

The GetPublicQueuesByMachine method does't find this queue and gives the Unhandled Execution Error and MessageQueueException with message text as NULL.

But GetPrivateQueuesByMachine method works fine and retrieves all private queues. Another thing is, if the same code is run in a Windows Application, it works fine and retrieves the public queue.
So why does it not find the PUBLIC queue in a WEB application?  here is my code. Please help.

if (!MessageQueue.Exists(".\\requestq"))                        //???
{
   MessageQueue requestq = MessageQueue.Create(".\\requestq");
}

MessageQueue[] mqlist = null;
try
{
   mqlist = MessageQueue.GetPublicQueuesByMachine(".");         //???
}
catch (MessageQueueException ex)
{
   string mesg = ex.Message;
}
0
Comment
Question by:engg
  • 4
  • 2
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17905564
According to this article

   http://msdn2.microsoft.com/en-us/library/system.messaging.messagequeue.exists.aspx

you seem to have everything correct, but with ASP.NET it may be a problem with authentication.  If you allow anonymous access to the web site, a special user with limited access is used to access external resources, such as message queues.

Bob
0
 

Author Comment

by:engg
ID: 17907110
Thanks Bob. How could that be done?
(I am using forms authentication if it has any relevance.)
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17937431
One idea would be to use impersonation:

ASP.NET Impersonation
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconImpersonation.asp

Bob
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:engg
ID: 17938341
Thanks Bob. I will look into it and will get back.
0
 

Author Comment

by:engg
ID: 18057289
Private queues are serving the purpose for the time being.
I will look into public queues soon.
0
 

Author Comment

by:engg
ID: 18199014
sorry about the delay.
Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question