0

I have a public message queue on my local machine that I created with my user account. I have a Windows service also on my local machine that runs under a corporate service account. I have granted the service account full access to the queue, and yet when the service is running, it can't seem to read the messages on the queue. I feel like I'm missing something rather basic, but I haven't been able to figure out what it is.

Code:

string queuePath = "FormatName:DIRECT=TCP:127.0.0.1\MyQueue";
MessageQueue _queue = new MessageQueue(queuePath);

When I step through the code, after the _queue object is created, the CanRead property is always false. I've tried several different ways of setting the queue path ("DIRECT=OS:.\MyQueue", "PUBLIC=[guid]", and without using a format name as well), but nothing has been successful.

The MSDN documentation states that "CanRead is false if a queue is already open with exclusive read access (or if it's open with non-exclusive access and this MessageQueue requests exclusive access), or if the application does not have sufficient rights to access it."

I've made sure that the application has sufficient rights (I think), but how can I tell if something else has "exclusive read access" to it? Is there anything else I'm missing?

Thanks.

howcheng
  • 2,211
  • 2
  • 17
  • 24
  • 1
    Well, this is embarrassing. It turns out I had set the ACLs for the _wrong service account_. Once I changed it to the correct account, it was happy. Nothing to see here, folks, move along. – howcheng Mar 27 '12 at 21:40

1 Answers1

2

Why are you using public queues? You should try re-create the queue as private (queue address will change to FORMATNAME:DIRECT=TCP:127.0.0.1\PRIVATE$\MyQueue) and see if this resolves your issue.

I have been using MSMQ for five years and have never used a public queue. I don't actually understand what they're for. But from experience people who try to use them usually have much more difficulty around authentication.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
  • I can confirm this. In all cases we ended up with private qs and direct format names. – Peter Aron Zentai Mar 27 '12 at 20:46
  • 1
    The difference between public and private queues: [link](http://msdn.microsoft.com/en-us/library/windows/desktop/ms706878%28v=vs.85%29.aspx). We need the extra AD-linked security plus having the queue registration backed up centrally. I can't use a private queue for a company-wide system. – howcheng Mar 27 '12 at 21:28
  • 1
    Hugh, Public queues are objects in Active Directory. The people that have problems with public queues usually have limited experience with Active Directory and domain/forest security. – John Breakwell Mar 28 '12 at 15:59