?
Solved

accessing public message queues

Posted on 2006-11-08
7
Medium Priority
?
742 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
6 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

809 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